prometheus / cloudwatch_exporter

Metrics exporter for Amazon AWS CloudWatch
Apache License 2.0
906 stars 326 forks source link

[request]: Support for Cloudwatch namespace ECS/ContainerInsights #448

Open mermino opened 2 years ago

mermino commented 2 years ago

Proposal

Use case. Why is this important?

To collect metrics for ECS containers!

How do you think the new configuration should look like?

Example:

- aws_namespace: ECS/ContainerInsights
  aws_metric_name: NetworkTxBytes
  aws_dimensions: [ClusterName, ServiceName, EC2InstanceId, ContainerInstanceId, TaskDefinitionFamily]
  aws_statistics: [Average]

- aws_namespace: ECS/ContainerInsights
  aws_metric_name: TaskCount
  aws_dimensions: [ClusterName, ServiceName, EC2InstanceId, ContainerInstanceId, TaskDefinitionFamily]
  aws_statistics: [Average]

- aws_namespace: ECS/ContainerInsights
  aws_metric_name: DesiredTaskCount
  aws_dimensions: [ClusterName, ServiceName, EC2InstanceId, ContainerInstanceId, TaskDefinitionFamily]
  aws_statistics: [Average]
matthiasr commented 2 years ago

I am not sure what the request is here. The exporter generically interacts with CloudWatch, and fetching these metrics should work. With the configuration you provided, what happens?

matthiasr commented 2 years ago

I am not using ECS, so I can't test. Could you share how you would get the metrics using the AWS CLI?

robert-becker-hs commented 1 year ago

@mermino First check: do you have containerInsights enabled for the ECS service? Also, looking at your aws_dimensions they seem a little too crowded though I can only comment on the dimensions for ECS Fargate. I am able to see ContainerInsight metrics in Prometheus using this config for cloudwatch-exporter:

...
  - aws_namespace: ECS/ContainerInsights
    aws_metric_name: RunningTaskCount
    aws_statistics: [Average, Minimum]
    aws_dimensions: [ClusterName, ServiceName]
    aws_dimension_select_regex:
      ClusterName: ["<cluster-name>/foo*"]
    set_timestamp: false
...

This is a screenshot from Cloudwatch showing me the metrics dimensions: Screenshot 2023-06-13 at 17 58 10