ECS and Fargate monitoring with CloudWatch metrics, alarms, and EventBridge

Andreas Wittig – 14 Nov 2026

Amazon ECS is good at hiding problems. A container crashes, the service scheduler starts a new task, that one crashes too, and the loop continues quietly in the background. A deployment never finishes because the new tasks fail their health checks. A service on Fargate Spot loses its only task and waits for capacity. In all of these cases, the ECS console shows the details to whoever happens to look, but nobody gets an alert, and your customers notice before you do.

ECS and Fargate monitoring with CloudWatch metrics, alarms, and EventBridge

This blog post teaches you how to monitor Amazon ECS services running on AWS Fargate or Amazon EC2. You will learn which CloudWatch metrics matter, which alarms we recommend, which EventBridge events you should never miss, and how to set it all up with CloudFormation. At the end, you will receive ECS alerts in Slack or Microsoft Teams.

What can go wrong with ECS and Fargate

Containers on ECS fail in ways a CPU graph doesn’t show. These are the failures we see most often:

  • Tasks fail to start. A missing image, a wrong IAM role, or an unreachable secret stops the task before your code runs.
  • An essential container exits. The application crashes, ECS stops the task, and the service starts a new one, again and again.
  • A deployment fails. The new task definition never reaches a steady state, and the service is stuck between two versions or rolls back.
  • Tasks can’t be placed. On EC2, the cluster runs out of CPU or memory. On Fargate Spot, there is no spare capacity.
  • The service runs out of resources. Memory runs full and the container is killed, or CPU is saturated and requests time out.

Metrics feed CloudWatch alarms, ECS events feed EventBridge rules, and both deliver alerts via SNS

Some of these failures show up in metrics, others only as events. That’s why a complete ECS monitoring setup combines CloudWatch alarms and EventBridge rules.

CloudWatch metrics for ECS services

Out of the box, ECS sends the following metrics to the AWS/ECS namespace at one-minute intervals, for free:

  • CPUUtilization and MemoryUtilization with the dimensions ClusterName and ServiceName: the CPU and memory in use by the service’s tasks, as a percentage of what the tasks reserved. These service-level metrics are available for Fargate and EC2.
  • CPUReservation and MemoryReservation with the dimension ClusterName: how much of the cluster’s EC2 capacity is reserved by tasks. These metrics only exist for tasks hosted on EC2 instances.

There is a catch: ECS only reports metrics for resources with tasks in the RUNNING state. A service that dropped to zero tasks stops sending data, and an alarm on CPUUtilization won’t notice.

That’s where Container Insights comes in. Once enabled for a cluster, it publishes additional metrics to the ECS/ContainerInsights namespace, among them:

  • RunningTaskCount, PendingTaskCount, and DesiredTaskCount per service.
  • EphemeralStorageUtilized and EphemeralStorageReserved for tasks on Fargate (Linux platform version 1.4.0 or later).
  • RestartCount for containers with a restart policy.

Container Insights isn’t free, so check CloudWatch pricing before you turn it on for many clusters. For production services, the running task count alone is worth it.

We recommend the following alarms per ECS service. The thresholds follow the AWS recommended alarms: every alarm uses a period of 60 seconds and fires after 5 out of 5 datapoints breach the threshold.

Metric Namespace Statistic Threshold Why
CPUUtilization AWS/ECS Average > 80 % Requests slow down before CPU hits 100 %. Scale out or increase the task size.
MemoryUtilization AWS/ECS Average > 80 % A container that exceeds its memory limit is killed.
RunningTaskCount ECS/ContainerInsights Average <= 0 The service is down. Raise the threshold to your minimum task count.
EphemeralStorageUtilized ECS/ContainerInsights Average > 90 % of reserved A full disk breaks logs, uploads, and temp files on Fargate.
CPUReservation AWS/ECS Average > 80 % EC2 only: new tasks won't fit into the cluster soon.
MemoryReservation AWS/ECS Average > 80 % EC2 only: same as above, for memory.

Set treat missing data to breaching for the RunningTaskCount alarm. Without data, the safest assumption is that no task is running.

If your service sits behind an Application Load Balancer, add alarms for the target group as well, for example on HTTPCode_Target_5XX_Count and TargetResponseTime. Read Monitoring: Application Load Balancer to learn which ALB alarms marbot creates. To reduce the number of alarms and their costs, check out how to combine metrics with metric math.

EventBridge events you should never miss

Metrics can’t tell you why a task stopped or that a deployment failed. ECS sends events to Amazon EventBridge for that. These are the ones worth an alert:

Detail type Filter What happened
ECS Task State Change lastStatus = STOPPED, stopCode = TaskFailedToStart A task failed to start.
ECS Task State Change lastStatus = STOPPED, stopCode = EssentialContainerExited An essential container exited, and ECS stopped the task.
ECS Task State Change stopCode = SpotInterruption Fargate Spot interrupts the task in two minutes.
ECS Service Action eventType = WARN or ERROR For example SERVICE_TASK_START_IMPAIRED or SERVICE_TASK_PLACEMENT_FAILURE.
ECS Deployment State Change eventName = SERVICE_DEPLOYMENT_FAILED A deployment failed.

Two details are easy to overlook:

  • SERVICE_DEPLOYMENT_FAILED is only sent for services with the deployment circuit breaker turned on. Without it, a broken deployment keeps retrying and never fails. Turn it on, ideally with rollback.
  • SERVICE_TASK_PLACEMENT_FAILURE includes a reason such as RESOURCE:CPU or RESOURCE:FARGATE, which tells you whether the cluster is full or Fargate Spot has no capacity.

Set it up with CloudFormation

The following template enables Container Insights for a new cluster, creates the RunningTaskCount alarm, and creates EventBridge rules for the events above. All alerts go to an existing SNS topic. The topic’s access policy must allow events.amazonaws.com to publish to it, or EventBridge can’t deliver the events.

AWSTemplateFormatVersion: '2010-09-09'
Description: 'ECS monitoring: running tasks alarm and EventBridge rules'
Parameters:
ClusterName:
Type: String
ServiceName:
Type: String
TopicArn:
Type: String
Description: 'ARN of an existing SNS topic that receives the alerts'
Resources:
Cluster:
Type: 'AWS::ECS::Cluster'
Properties:
ClusterName: !Ref ClusterName
ClusterSettings:
- Name: containerInsights
Value: enabled
RunningTaskCountAlarm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmDescription: 'ECS service runs no tasks'
Namespace: 'ECS/ContainerInsights'
MetricName: RunningTaskCount
Dimensions:
- Name: ClusterName
Value: !Ref ClusterName
- Name: ServiceName
Value: !Ref ServiceName
Statistic: Average
Period: 60
EvaluationPeriods: 5
DatapointsToAlarm: 5
Threshold: 0
ComparisonOperator: LessThanOrEqualToThreshold
TreatMissingData: breaching
AlarmActions:
- !Ref TopicArn
OKActions:
- !Ref TopicArn
TaskStoppedRule:
Type: 'AWS::Events::Rule'
Properties:
EventPattern:
source:
- 'aws.ecs'
detail-type:
- 'ECS Task State Change'
detail:
clusterArn:
- !GetAtt Cluster.Arn
lastStatus:
- STOPPED
stopCode:
- TaskFailedToStart
- EssentialContainerExited
Targets:
- Arn: !Ref TopicArn
Id: sns
ServiceActionRule:
Type: 'AWS::Events::Rule'
Properties:
EventPattern:
source:
- 'aws.ecs'
detail-type:
- 'ECS Service Action'
detail:
clusterArn:
- !GetAtt Cluster.Arn
eventType:
- WARN
- ERROR
Targets:
- Arn: !Ref TopicArn
Id: sns
DeploymentFailedRule:
Type: 'AWS::Events::Rule'
Properties:
EventPattern:
source:
- 'aws.ecs'
detail-type:
- 'ECS Deployment State Change'
resources:
- !Sub 'arn:${AWS::Partition}:ecs:${AWS::Region}:${AWS::AccountId}:service/${ClusterName}/${ServiceName}'
detail:
eventName:
- SERVICE_DEPLOYMENT_FAILED
Targets:
- Arn: !Ref TopicArn
Id: sns

To make sure the deployment rule ever fires, turn on the deployment circuit breaker in your AWS::ECS::Service:

DeploymentConfiguration:
DeploymentCircuitBreaker:
Enable: true
Rollback: true

Add the CPUUtilization and MemoryUtilization alarms from the table the same way, with the namespace AWS/ECS and the comparison operator GreaterThanThreshold.

Send ECS alerts to Slack or Microsoft Teams

E-mails from SNS are easy to ignore, and the raw event JSON doesn’t tell you what to do next. marbot delivers ECS alerts to the channel where your team already works, and makes sure somebody acknowledges each one.

The Monitoring Assistant creates the EventBridge rules for ECS for you. You get alerted when a task fails to start, when an essential container of a standalone task exits with a non-zero exit code, when a service fails, and when a deployment fails or succeeds. See Monitoring: Amazon ECS for the details. For Fargate Spot, marbot notifies you about interruptions as well.

Monitoring Assistant
Tired of writing EventBridge patterns? Ask marbot to monitor your ECS services and receive alerts in Slack or Microsoft Teams!

  1. Add marbot to Slack or Microsoft Teams.
  2. Invite marbot to a channel.
  3. Follow the setup wizard.
It couldn't be easier!

Want to dig deeper into monitoring containers on AWS? I’ve written about the five priorities for monitoring container workloads on cloudonaut.io. Do you have any questions? Please send a message to hello@marbot.io.

Andreas Wittig

Andreas Wittig

Building micro-SaaS on AWS.

You can contact me via Email, Twitter, and LinkedIn.

Published on

marbot teaser

Chatbot for AWS Monitoring

Configure monitoring for Amazon Web Services: CloudWatch, EC2, RDS, EB, Lambda, and more. Receive and manage alerts via Slack. Solve incidents as a team.

Slack
Add to Slack
Microsoft Teams
Add to Teams