Configuring and Troubleshooting Alarm Evaluation
This lesson explains exactly when a CloudWatch alarm changes state, watching a metric, a metric math expression or an anomaly band, which is essential for configuring and troubleshooting alarms.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the OK, ALARM and INSUFFICIENT_DATA states.
- Configure period, evaluation periods and datapoints to alarm.
- Choose how missing data is treated.
- Diagnose an alarm that never fires.
Alarm states
An alarm is always in one of three states. OK means the metric is within the threshold. ALARM means it has breached the threshold for the required number of datapoints. INSUFFICIENT_DATA means the alarm has just started, the metric is not available, or not enough data exists to decide. Actions can be attached to each state, so an alarm can notify when it enters ALARM and again when it returns to OK.
Period, evaluation periods and datapoints to alarm
Three settings control sensitivity. The period is the length of time over which the statistic is calculated for each datapoint. Evaluation periods (N) is how many recent datapoints are considered. Datapoints to alarm (M) is how many of those N must breach. A setting of 3 out of 3 with a 1-minute period requires three consecutive breaching minutes; 3 out of 5 tolerates brief recoveries and reduces flapping on noisy metrics. The time before an alarm can fire is roughly the period multiplied by M, plus metric publishing delay.
The following diagram applies two settings to the same five datapoints.

M out of N
Missing data treatment
Metrics sometimes stop reporting: an instance is stopped, a Lambda function is not invoked, or an error-count metric publishes nothing when there are no errors. The treat missing data setting decides how the alarm interprets gaps. The following table describes the four options.
| Setting | Effect | Use when |
|---|---|---|
| missing (default) | Gaps are ignored when evaluating; if all datapoints are missing the alarm goes to INSUFFICIENT_DATA | The metric should always report |
| notBreaching | Gaps count as within the threshold | Sparse metrics such as error counts, where no data means no errors |
| breaching | Gaps count as breaching | Missing data itself signals failure, such as a heartbeat metric |
| ignore | The alarm keeps its current state | Intermittent metrics where state should not change on gaps |
The following diagram shows how each setting interprets the same gaps.

Missing data options
An alarm that never fires
A team creates an alarm on Errors for a Lambda function with Statistic Average, threshold 5, period 5 minutes and 1 of 1 datapoints. During an incident the function returns 40 errors out of 4,000 invocations in five minutes, yet the alarm stays OK. Each invocation contributes a value of 1 (failed) or 0 (succeeded) to the Errors series, so the Average over the period is the error rate, here 40 / 4,000 = 0.01, which can never exceed 5. The fix is to use the Sum statistic (40 breaches 5) or to alarm on an error rate computed with metric math. Because the metric publishes nothing when the function is not invoked, missing data should be treated as notBreaching to avoid INSUFFICIENT_DATA overnight.
How should missing data be treated for a heartbeat metric?
Show answer
As breaching, because a missing heartbeat means the sender has stopped.
Exam Tips
Remember for the exam
- Alarm states are OK, ALARM and INSUFFICIENT_DATA; actions can be attached to each.
- M out of N datapoints reduces false alarms on noisy metrics.
- Treat missing data as notBreaching for sparse error metrics and breaching for heartbeats.
- Use the Sum statistic for counts; Average of a count metric is a frequent mistake.