Troubleshooting CloudWatch Alarm State Transitions: OK, ALARM, and INSUFFICIENT_DATA
Amazon CloudWatch alarms transition between OK, ALARM, and INSUFFICIENT_DATA states based on metric evaluation periods, threshold comparisons, and missing data handling configurations.
Troubleshooting unexpected CloudWatch alarm state transitions requires understanding how AWS evaluates metrics against thresholds over configurable time windows. The aws/agent-toolkit-for-aws repository provides detailed diagnostic procedures in skills/core-skills/aws-observability/references/alarms.md for resolving issues when alarms unexpectedly shift between OK, ALARM, and INSUFFICIENT_DATA states.
How CloudWatch Alarm State Transitions Work
CloudWatch alarms monitor metric data through a multi-step evaluation process that determines state transitions:
-
Metric ingestion – CloudWatch receives metric data from AWS services (EC2, Lambda, etc.) or custom
PutMetricDataAPI calls. -
Evaluation periods – An alarm evaluates a configurable number of recent periods (the EvaluationPeriods parameter). Each period must contain at least one datapoint; otherwise, the alarm enters INSUFFICIENT_DATA.
-
Threshold comparison – The alarm compares the aggregated metric value (Average, Sum, Minimum, Maximum, or percentile) against the defined threshold. If the result exceeds the threshold for the configured number of consecutive periods, the state becomes ALARM; otherwise, it returns to OK.
-
State persistence – CloudWatch maintains the previous state to prevent flapping, but missing datapoints or misconfigured dimensions can trigger abrupt transitions.
Common Causes of Unexpected CloudWatch Alarm State Changes
OK to INSUFFICIENT_DATA Transitions
This transition occurs when no metric data arrives for the required EvaluationPeriods. Common causes include the source service stopping, network connectivity issues, or IAM permission errors preventing cloudwatch:PutMetricData calls. Verify the metric source is still publishing and check IAM policies for the publishing role.
INSUFFICIENT_DATA to ALARM Transitions
A single out-of-range datapoint arriving after a period of missing data can trigger this transition. The alarm treats the first datapoint as a valid evaluation. Increase the DatapointsToAlarm setting or configure the TreatMissingData option to control default behavior when data resumes.
Rapid State Flapping Between OK and ALARM
Metric spikes from burst traffic or noisy data often cause rapid transitions. This typically indicates insufficient smoothing from low Period or EvaluationPeriods values. Adjust the period length to match the metric's natural frequency, increase evaluation periods to ≥ 2, or apply statistical smoothing using percentiles.
Alarm Stuck in ALARM State After Issue Resolution
Alarms may remain in ALARM state when CloudWatch does not receive new datapoints to trigger re-evaluation. Ensure the metric source continues to emit data regularly, and configure EvaluationPeriods greater than 1 to enable automatic state reset when metrics normalize.
Missing CloudWatch Logs for Alarm Metrics
When metrics derive from logs (e.g., Lambda, EC2 agents), missing logs indicate VPC endpoint misconfiguration or missing IAM permissions. Verify the com.amazonaws.<region>.logs VPC endpoint exists for isolated subnets, or confirm the IAM role includes logs:PutLogEvents and cloudwatch:PutMetricData permissions.
Diagnostic Workflow for CloudWatch Alarms
According to the troubleshooting guide in skills/core-skills/aws-observability/references/alarms.md, follow this systematic workflow:
-
Inspect the alarm definition – Use the AWS CLI or Console to verify the metric, period, evaluation periods, and TreatMissingData configuration.
-
Check metric data – Query the underlying metric for recent periods to confirm datapoint presence and values.
-
Review CloudWatch logs – Examine log groups (e.g.,
/aws/lambda/<function-name>) for the metric source to identify publishing failures. -
Verify IAM permissions – Ensure the publishing role has
cloudwatch:PutMetricDataand relevant logging permissions. -
Validate network connectivity – For VPC resources, confirm the CloudWatch Logs VPC endpoint (
com.amazonaws.<region>.logs) is configured and security groups allow egress. -
Adjust alarm configuration – Modify TreatMissingData (set to
notBreachingorbreaching), increase EvaluationPeriods, or adjust thresholds based on findings.
CloudWatch Alarm Configuration Best Practices
The skills/core-skills/aws-observability/SKILL.md file recommends these settings to minimize false state transitions:
-
Period – Match the metric's natural frequency. Use 60 seconds for high-frequency metrics and 300 seconds for slower-moving ones.
-
EvaluationPeriods – Set to ≥ 2 to prevent state flapping from single anomalous datapoints.
-
TreatMissingData – Choose
notBreachingfor standard metrics (e.g., request count) andbreachingfor critical failure indicators (e.g., error counts). -
DatapointsToAlarm – Configure fewer datapoints than evaluation periods (e.g., 2 out of 3) to allow for intermittent data gaps without triggering false alarms.
-
Alarm actions – Attach SNS topics or OpsItem actions only after validating the alarm reliably reflects the metric state.
-
Log retention – Enable 30-day CloudWatch Logs retention to preserve diagnostic data for troubleshooting historical state transitions.
AWS CLI Commands for Troubleshooting Alarm State Transitions
Use these commands to diagnose CloudWatch alarm issues:
Describe alarm configuration:
aws cloudwatch describe-alarms \
--alarm-names MyHighCPUAlarm \
--query 'MetricAlarms[0].{Name:AlarmName,State:StateValue,Period:Period,EvalPeriods:EvaluationPeriods,TreatMissing:TreatMissingData}'
Fetch recent metric datapoints:
aws cloudwatch get-metric-statistics \
--namespace AWS/EC2 \
--metric-name CPUUtilization \
--dimensions Name=InstanceId,Value=i-0123456789abcdef0 \
--statistics Average \
--period 60 \
--start-time $(date -u -d '5 minutes ago' +%Y-%m-%dT%H:%M:%SZ) \
--end-time $(date -u +%Y-%m-%dT%H:%M:%SZ)
Update alarm to ignore missing data:
aws cloudwatch put-metric-alarm \
--alarm-name MyHighCPUAlarm \
--metric-name CPUUtilization \
--namespace AWS/EC2 \
--statistic Average \
--period 60 \
--evaluation-periods 3 \
--threshold 80 \
--comparison-operator GreaterThanThreshold \
--treat-missing-data notBreaching \
--alarm-actions arn:aws:sns:us-east-1:123456789012:MyTopic
Verify VPC endpoint for CloudWatch Logs:
aws ec2 describe-vpc-endpoints \
--filters Name=service-name,Values=com.amazonaws.*.logs
Summary
- CloudWatch alarms transition between OK, ALARM, and INSUFFICIENT_DATA based on metric availability and threshold evaluation over configured periods.
- Unexpected transitions typically stem from missing data, insufficient evaluation periods, or network/IAM issues preventing metric ingestion.
- The diagnostic workflow involves verifying alarm configurations, checking metric data availability, reviewing logs, and validating IAM and network settings.
- Configure EvaluationPeriods ≥ 2 and appropriate TreatMissingData settings to prevent false state transitions.
- Reference
skills/core-skills/aws-observability/references/alarms.mdin theaws/agent-toolkit-for-awsrepository for detailed troubleshooting procedures.
Frequently Asked Questions
Why does my CloudWatch alarm constantly flip between OK and ALARM states?
Rapid state transitions indicate noisy metrics or insufficient smoothing. This occurs when the Period is too short for the metric's volatility or when EvaluationPeriods is set to 1. Increase the evaluation period to at least 2 consecutive periods, adjust the period length to match the metric's natural cadence, or use statistical aggregations like percentiles to smooth out spikes.
What causes a CloudWatch alarm to remain in INSUFFICIENT_DATA?
The INSUFFICIENT_DATA state persists when CloudWatch receives no datapoints for the configured EvaluationPeriods. Check that the metric source is actively publishing data, verify the IAM role has cloudwatch:PutMetricData permissions, and ensure network connectivity exists via VPC endpoints or internet gateways. For custom metrics, confirm the dimensions match exactly between the publishing code and alarm configuration.
How do I prevent false alarms from missing metric data?
Configure the TreatMissingData parameter to notBreaching for metrics where missing data should not trigger alerts (e.g., request counts during low-traffic periods). Set DatapointsToAlarm lower than EvaluationPeriods (e.g., 2 out of 3) to tolerate intermittent data gaps. Alternatively, use the breaching setting for critical metrics where silence indicates a failure.
Why does my alarm stay in ALARM state after the underlying issue is resolved?
Alarms remain in ALARM state until CloudWatch receives sufficient datapoints below the threshold to trigger a new evaluation. If the metric source stopped publishing during the incident, the alarm cannot evaluate recovery. Ensure continuous metric publication, verify the threshold is appropriately set for normal operating levels, and check that EvaluationPeriods is configured to allow recovery detection within your desired timeframe.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →