Monitoring Containers with Container Insights
This lesson explains how CloudWatch Container Insights collects cluster, service, task, pod and container metrics and container logs for Amazon ECS and Amazon EKS.
Learning outcomes
After completing this lesson, you will be able to:
- Enable Container Insights on ECS.
- Install Container Insights on EKS with the Observability add-on.
- Diagnose restarting tasks from Container Insights metrics.
Container Insights on Amazon ECS
On Amazon ECS, Container Insights is enabled per cluster (or as an account default) with the containerInsights cluster setting. Standard Container Insights publishes cluster and service metrics such as CPU and memory utilisation, running task count and network traffic; Container Insights with enhanced observability adds task-level and container-level detail and curated dashboards for faster troubleshooting. For tasks on Fargate, metrics are collected automatically. For clusters on EC2 container instances, the CloudWatch agent can run as a daemon service for instance-level metrics.
Application logs from ECS tasks are sent with the awslogs log driver, configured in the task definition with a log group, Region and stream prefix, or with FireLens, which runs Fluent Bit as a sidecar to route logs to CloudWatch Logs, Firehose, S3 or partners. The task execution role needs permission to write logs.
Container Insights
Container Insights on Amazon EKS
On Amazon EKS, the recommended installation is the Amazon CloudWatch Observability EKS add-on. It deploys the CloudWatch agent and Fluent Bit as DaemonSets, which collect node, pod and container metrics (with enhanced observability by default) and container logs. The worker nodes' IAM role, or an EKS Pod Identity association for the agent's service account, needs CloudWatchAgentServerPolicy. The add-on can also enable CloudWatch Application Signals for supported languages. Clusters can alternatively send Prometheus metrics to Managed Service for Prometheus, covered in the dashboards module.
The following table summarises how metrics and logs are collected for each container platform.
| Platform | Metrics | Logs |
|---|---|---|
| ECS on Fargate | Container Insights cluster setting | awslogs driver or FireLens |
| ECS on EC2 | Container Insights setting plus CloudWatch agent daemon service | awslogs driver or FireLens |
| EKS (EC2 nodes) | CloudWatch Observability add-on (agent DaemonSet) | Fluent Bit DaemonSet from the add-on |
| EKS (Fargate) | Container Insights through the ADOT collector | Fargate built-in Fluent Bit log router |
The following diagram shows what the add-on deploys on each node.

Tasks restarting repeatedly
An ECS service on Fargate keeps replacing tasks. Container Insights shows memory utilisation for the service climbing to 100% before each task stops. The stopped task's stoppedReason in the console or describe-tasks reads OutOfMemoryError: Container killed due to memory usage, and exit code 137 confirms it. The team raises the task's memory from 1 GB to 2 GB in a new task definition revision and adds a CloudWatch alarm on the service's MemoryUtilized relative to MemoryReserved so that the next memory leak is caught before tasks are killed.
How are Container Insights metrics and logs enabled on Amazon EKS?
Show answer
By installing the Amazon CloudWatch Observability add-on.
Exam Tips
Remember for the exam
- ECS Container Insights is a cluster setting; enhanced observability adds task and container detail.
- EKS: install the CloudWatch Observability add-on for metrics and logs.
- ECS logs use the awslogs driver or FireLens; the task execution role needs log permissions.
- Exit code 137 with OutOfMemoryError means the container exceeded its memory limit.