Skip to content

CloudWatch Alarm evaluates 100% but CloudWatch Metrics graph shows only 20% for the same math expression

0

Hi, I'm seeing an inconsistency between a CloudWatch Alarm and the CloudWatch Metrics graph, and I'd like to know whether this is expected behavior or if I'm missing something.

<Environment> ・Amazon ECS (Fargate) ・Container Insights enabled ・Task runs once a day for about 5 minutes ・One task definition with one container <Alarm configuration> The alarm monitors CPU utilization using a math expression. `Expression: (m1 / m2) * 100

m1 = ECS/ContainerInsights / CpuUtilized (Average) m2 = ECS/ContainerInsights / CpuReserved (Average)

Period: 5 minutes Statistic: Average Threshold: >80 Evaluation: 1 out of 1 datapoints Missing data: Treat missing as missing`

<What I observed> For example: The Metrics graph shows only one datapoint: `15:05 UTC CpuUtilized = 102.4 CpuReserved = 512 Expression = 20`

The calculation is correct: 102.4 / 512 * 100 = 20%

However, the alarm history reports: "recentDatapoints": [ 100 ], The alarm entered ALARM because it evaluated approximately 100%, even though the Metrics graph only shows 20%.

<Additional information> ・The ECS task completed successfully. ・No CPU throttling or task failures were observed. ・This has happened multiple times. <Question> Is there any reason why a CloudWatch Alarm would evaluate a different value from what is shown in the CloudWatch Metrics graph for the same metric math expression?

Are there any known behaviors related to: ・Metric Math evaluation timing ・Container Insights aggregation ・Alarm evaluation using datapoints that are not displayed in the Metrics graph ・Short-lived ECS tasks (around 5 minutes)

Any guidance would be appreciated. Thank you.

1 Answer
0
Accepted Answer

Yes, this is expected behavior and relates to how CloudWatch handles delayed or late-arriving data points.

When your alarm evaluated at the specific moment, it used the data available at that time. However, AWS services (including Container Insights) can publish additional data points for the same timestamp after the alarm has already made its evaluation decision. When these delayed data points arrive, the CloudWatch Metrics graph recalculates and displays the updated aggregated value, but the alarm's decision was already made based on the earlier data.

In your case, the alarm likely evaluated when it had incomplete or different data points, calculated approximately 100%, and triggered the ALARM state. Later, when additional data points arrived for the same 15:05 UTC timestamp, the graph recalculated the average to show 20%.

This is particularly common with short-lived workloads like your 5-minute ECS task, where metrics may be published with slight delays as the task completes and Container Insights processes the data.

To verify what actually triggered your alarm, the Alarm History is your source of truth—not the Metrics graph. You can check the History tab in the CloudWatch console for your alarm and review the "State update" entries. The "New state reason" field will show the exact metric value that CloudWatch used during evaluation.

To reduce these discrepancies in the future, you could:

  • Match your alarm period to the metric publishing interval (Container Insights typically publishes at 1-minute intervals)
  • Consider using a longer evaluation period to allow more time for all data points to arrive before evaluation
  • Be aware that for batch or short-lived workloads, some timing discrepancies between alarm evaluations and graph displays are normal

The key takeaway is that the alarm evaluated correctly based on the data available when it ran—the graph simply shows a different view after late-arriving data was incorporated.
Sources
Troubleshoot inconsistent CloudWatch metric values and data gaps | AWS re:Post
Understanding CloudWatch Alarm Evaluation: Why Alarms Delay, Fire Unexpectedly, or Get Stuck | AWS re:Post

answered a month ago

EXPERT

reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.