epok
View as Markdown

AWS ECS logs and metrics

Updated Nov 22, 2026 · today

With the awslogslog driver, ECS sends each container's output to a CloudWatch Logs group, and publishes task and service metrics under the AWS/ECS namespace. Both reach Epok through the shared setup on AWS: logs and metrics.

On this page: What you getTurn on logsMetricsUseful searchesTroubleshooting

What you get

  • Logs:each container's stdout and stderr, from the log group you set in the task definition (for example /ecs/api).
  • Metrics: the AWS/ECS namespace, which includes CPU and memory utilization and reservation.

Each log event is stored with _msg, _time, a level detected from the line, service (the last part of the log group name), log_group, log_stream, cloud.provider, cloud.account_id and cloud.region.

Turn on logs

  1. In the task definition, set the log configuration to the awslogs driver with awslogs-group (the group name), awslogs-region and awslogs-stream-prefix. The task execution role needs logs:CreateLogStream and logs:PutLogEvents.
  2. Create the group ahead of time so it is not empty: aws logs create-log-group --log-group-name /ecs/<service>.
  3. Add the group to EPOK_LOG_GROUPS and run the setup on AWS: logs and metrics.

Metrics

The namespace is AWS/ECS. It is in the default metric stream list, so it arrives with the normal metrics setup.

text
log_group:"/ecs/api" level:error              # errors from one service
service:api _msg:"OOMKilled"                 # a specific crash, any task
level:error _time:1h | stats by (service) count()  # which services error the most
service:worker _msg:err*                     # prefix match on the message

Troubleshooting

  1. Group is empty. The task has not started, or the awslogsdriver points at a group the execution role cannot write to. Check the task's last status and the execution role policy.
  2. Service name is generic. service comes from the last part of the group name, so name the group /ecs/<your-service> rather than a shared group.
  3. Metrics missing. The metrics stack is separate from the logs stack and a fresh metric stream can take 3 to 15 minutes. Run bash aws-metrics.sh --verify-only.

Next