Soru

Zorluk: ZorCloudWatch Dashboards and Container Insights

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?

  1. 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.Cevap
  2. B
    Enable 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.
  3. C
    Modify 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.
  4. D
    Configure 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.

Cevap

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.

Adım Adım Çözüm

1
Identify where task-level metric details are stored in Container Insights.
Container Insights performance logs are stored in the CloudWatch Logs group /aws/ecs/containerinsights/{ClusterName}/performance.
Since standard CloudWatch metrics in the ECS/ContainerInsights namespace do not include the TaskId dimension to avoid high metric costs, task-level performance events must be retrieved from the log group.
2
Use CloudWatch Logs Insights to query the performance logs.
Write a query targeting the /aws/ecs/containerinsights/{ClusterName}/performance log group, filtering for records where the Type field equals 'Task', and selecting the TaskId and CpuUtilized fields.
This extracts the specific metric data for individual tasks directly from the performance log JSON payloads.
3
Add the Logs Insights query to the CloudWatch dashboard.
Save the query as a dashboard widget (such as a table or line chart).
This displays the live query results on the custom dashboard, meeting the requirement to monitor individual task CPU utilization.

Anahtar Kavram

Visualizing ECS Fargate task-level Container Insights metrics using CloudWatch Logs Insights query widgets on a dashboard.
Bu soruyu puanla