Interview Prep/AWS/CloudFormation, CloudWatch, KMS, Secrets and Cost

A CPU alarm flaps between `OK` and `ALARM` every few minutes and pages the on-call engineer all night.

IntermediateTroubleshootingCloudFormation, CloudWatch, KMS, Secrets and Cost
Answer

Likely causes → The alarm uses 1 datapoint of 1 over a short period on a noisy metric. Or missing data is treated as breaching while the metric is published irregularly.

Diagnose →

aws cloudwatch describe-alarm-history --alarm-name web-cpu --history-item-type StateUpdate --max-items 20 \
  --query 'AlarmHistoryItems[].[Timestamp,HistorySummary]'
aws cloudwatch describe-alarms --alarm-names web-cpu \
  --query 'MetricAlarms[].[Period,EvaluationPeriods,DatapointsToAlarm,TreatMissingData,Threshold]'

Fix →

aws cloudwatch put-metric-alarm --alarm-name web-cpu --namespace AWS/EC2 --metric-name CPUUtilization \
  --dimensions Name=AutoScalingGroupName,Value=web-asg --statistic Average --period 60 \
  --evaluation-periods 5 --datapoints-to-alarm 4 --threshold 85 --comparison-operator GreaterThanThreshold \
  --treat-missing-data notBreaching --alarm-actions <sns-arn>

Use composite alarms (for example, high CPU and high latency) for paging.

Prevent → Page on symptoms (SLO burn, errors, latency) and send resource alarms to tickets.

aws All AWS questions Roadmap: Cloud cost & architecture

More on CloudFormation, CloudWatch, KMS, Secrets and Cost