zmoog / public-notes

Apache License 2.0
0 stars 1 forks source link

Figure out how to collect ECS/ContainerInsights metrics using the CloudWatch metrics integration #43

Closed zmoog closed 1 year ago

zmoog commented 1 year ago

The basic ECS metrics do not have information about ECS tasks. Let's try with the ECS/ContainerInsights metrics.

zmoog commented 1 year ago

Install the AWS CloudWatch integration and enable the "Collect metrics from CloudWatch" integration:

CleanShot 2023-07-27 at 10 36 07@2x

Quick run with the default configuration to make sure authentication is set up correctly and we're getting data:

CleanShot 2023-07-27 at 10 41 29@2x

zmoog commented 1 year ago

The next step is to visit CloudWatch on the AWS console and check Metrics > All Metrics section to check which metrics have values:

CleanShot 2023-07-27 at 10 44 36@2x

zmoog commented 1 year ago

Metric docs

AWS has a nice page about Metrics collected by Container Insights that covers both ECS and EKS. For ECS, we can use the Amazon ECS Container Insights metrics page.

Configuration

With this information, I would start changing the default configuration file and replace EC2 metrics with some ECS/Container Insights metrics:

- namespace: ECS/ContainerInsights
  resource_type: ecs
  name:
    - CpuUtilized
    - CpuReserved
  statistic:
    - Average
    - Maximum
  # dimensions:
  #  - name: InstanceId
  #     value: i-123456
  # tags:
  #   - key: created-by
  #     value: foo
zmoog commented 1 year ago

With this config, I can get some basic metrics that include the aws.dimensions.TaskDefinitionFamily dimension:

CleanShot 2023-07-27 at 11 02 29@2x

zmoog commented 1 year ago

Remember to reload the Discover page if it was already open before Elasticsearch created the data stream; otherwise, it will not have the new fields definition available.