def get_ecs_stats()

in source/lambda/SendOperationalMetricsLambdaFunction.py [0:0]


def get_ecs_stats(ecs_cluster_name, config):
  client = boto3.client('ecs', config=config)
  response = client.describe_clusters(
    clusters=[
      ecs_cluster_name,
    ],
    include=['STATISTICS']
  )
  status = response.get('clusters')[0].get('status')
  statistics = response.get('clusters')[0].get('statistics')
  task_count = (next(item for item in statistics if item["name"] == "runningFargateTasksCount")).get('value')
  return status, task_count