A SysOps Administrator is configuring an Amazon CloudWatch dashboard to monitor an Amazon ECS service running on AWS Fargate. The Administrator has enabled Amazon CloudWatch Container Insights on the ECS cluster. The Administrator needs to display the CPU utilization of individual ECS tasks on the dashboard. However, when browsing the ECS/ContainerInsights namespace in CloudWatch Metrics, the Administrator only finds metrics aggregated at the cluster, service, and task definition family levels. Which action should the Administrator take to display the CPU utilization of individual tasks on the dashboard?
- Create a CloudWatch Logs Insights widget on the dashboard that queries the /aws/ecs/containerinsights/{ClusterName}/performance log group to extract and display task-level CPU utilization metrics from the performance log events.Answer
- BEnable detailed monitoring on the ECS service and task definitions to force CloudWatch to publish task-level metrics to the ECS/ContainerInsights namespace with 1-minute granularity.
- CModify the retention period of the /aws/ecs/containerinsights/{ClusterName}/performance log group to 1 day, which triggers CloudWatch to automatically summarize the performance logs and publish task-level metrics to the dashboard.
- DConfigure an Amazon EventBridge rule that matches ECS task state change events, and set the target to an AWS Systems Manager Automation document to extract performance data and write it to the dashboard.
Answer
Create a CloudWatch Logs Insights widget on the dashboard that queries the performance log group to extract and display the task-level CPU utilization.
For Amazon ECS clusters running on AWS Fargate, Container Insights aggregates metrics in the ECS/ContainerInsights namespace at the cluster, service, and task definition family levels to prevent high-cardinality costs. However, task-level performance events are still stored as JSON logs in CloudWatch Logs under the log group /aws/ecs/containerinsights/{ClusterName}/performance. To visualize task-level metrics like CPU utilization on a dashboard, the Administrator must write a CloudWatch Logs Insights query against this log group to parse the TaskId and CpuUtilized fields, and then pin the query to the dashboard as a widget.
Step-by-Step Solution
Key Concept
Visualizing ECS Fargate task-level Container Insights metrics using CloudWatch Logs Insights query widgets on a dashboard.