# ECS TaskCpuUtilization alarm for one service

CloudWatch alarms · Updated 17 November 2026

**Short answer:** This variant adds the ServiceName dimension, so it fires when the average task in one service uses more than 80% of its reserved CPU for 5 of 5 one-minute periods. Use it for the services you care about; the cluster-level alarm only shows that something somewhere is busy.

## Service-level task CPU versus the other CPU metrics

ECS has three overlapping ways to look at a service's CPU. Knowing which is which saves confusion when they disagree:

| Metric | Namespace | Needs | Notes |
|---|---|---|---|
| `CPUUtilization` | `AWS/ECS` | Nothing | Service total used / total reserved; on EC2 can exceed 100% |
| `TaskCpuUtilization` (cluster) | `ECS/ContainerInsights` | Enhanced observability | All tasks in the cluster averaged |
| `TaskCpuUtilization` (service) | `ECS/ContainerInsights` | Enhanced observability | Tasks of one service averaged; this page |

The practical advantage of the Container Insights version is that you can drill from it to individual tasks in the console, which matters when one task is stuck in a hot loop and the others are idle. It also keeps working the same way on Fargate and EC2, so one alarm definition fits services on either launch type.

## Recommended alarm settings

| Setting | Value |
|---|---|
| Namespace | `ECS/ContainerInsights` |
| Metric | `TaskCpuUtilization` |
| Dimensions | `ClusterName`, `ServiceName` |
| Statistic | `Average` |
| Period | 60 seconds |
| Datapoints to alarm | 5 |
| Evaluation periods | 5 |
| Comparison operator | `GreaterThanThreshold` |
| Threshold | 80.0 (percent) |

As published on the CloudWatch [recommended alarms](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html) page; compare the [cluster-level alarm](https://cloudconsole.dev/alarms/ecs-insights-taskcpuutilization), which drops the service dimension.

## Tuning per service

Set the threshold from the service's behaviour, not a house rule. Check two weeks of the Average and Maximum: a web API whose tasks peak at 55% can alarm at 75% and catch problems early; a CPU-heavy image processor that runs at 85% by design should alarm at 95% or watch its queue instead. If the service uses CPU target tracking, make sure the alarm threshold sits clearly above the scaling target, so the alarm means "scaling is not keeping up" rather than "scaling is about to happen".

## Create it

```
aws cloudwatch put-metric-alarm \
  --alarm-name prod-api-task-cpu \
  --namespace ECS/ContainerInsights \
  --metric-name TaskCpuUtilization \
  --dimensions Name=ClusterName,Value=prod Name=ServiceName,Value=api \
  --statistic Average \
  --period 60 \
  --evaluation-periods 5 \
  --datapoints-to-alarm 5 \
  --threshold 80 \
  --comparison-operator GreaterThanThreshold \
  --alarm-actions arn:aws:sns:eu-west-2:123456789012:ops-alerts \
  --region eu-west-2
```

## When it fires

1. **All tasks or one?** Compare Average and Maximum. If Maximum is at 100% while Average is modest, one task is the problem: stop it with [stop-task](https://cloudconsole.dev/cli/ecs-stop-task) and let the service replace it, after grabbing a thread dump if you can.
2. **All tasks busy:** check request volume and whether auto scaling is at its maximum; scale out if needed ([scale an ECS service](https://cloudconsole.dev/how-to/scale-ecs-service)).
3. **Load flat but CPU up:** look at the latest deployment; a regression in hot code paths is the likely cause.
4. **Persistently high after scaling:** raise task CPU in the task definition.

Remember that on Fargate the CPU and memory sizes come in fixed combinations, so a bigger CPU allocation may also mean paying for more memory; check whether the extra cost is better spent on more tasks instead.

## Questions

### Why use TaskCpuUtilization instead of ECS CPUUtilization?

Both work for alarms. The Container Insights metric comes with task-level detail in the console, which helps find a single hot task.

### What threshold should I use for task CPU?

AWS suggests 80%. Adjust it per service from its normal peak, keeping it above any auto scaling target.

### Does TaskCpuUtilization work on Fargate?

Yes. Enhanced observability publishes task metrics for both Fargate and EC2 launch types.

## When this happens away from your desk

When one service is running hot, the question is whether to scale or roll back. CloudConsole, a phone app for AWS, is built to show this alarm with the service's task count and last deployment on a phone.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Recommended alarms for AWS services (Amazon CloudWatch User Guide)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Best_Practice_Recommended_Alarms_AWS_Services.html)
- [Amazon ECS Container Insights metrics](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-metrics-ECS.html)

## Related

- [CloudWatch alarm for ECS TaskCpuUtilization (cluster level)](https://cloudconsole.dev/alarms/ecs-insights-taskcpuutilization)
- [CloudWatch alarm for Amazon ECS service CPUUtilization](https://cloudconsole.dev/alarms/ecs-cpuutilization)
- [ECS ContainerCPUUtilization alarm by container name](https://cloudconsole.dev/alarms/ecs-insights-containercpuutilization-per-service)
- [aws ecs stop-task](https://cloudconsole.dev/cli/ecs-stop-task)
- [How to scale an ECS service](https://cloudconsole.dev/how-to/scale-ecs-service)
- [CloudWatch alarm for ECS ContainerCpuUtilization (cluster level)](https://cloudconsole.dev/alarms/ecs-insights-containercpuutilization)

---

Source: https://cloudconsole.dev/alarms/ecs-insights-taskcpuutilization-per-service

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
