Interview Prep/Monitoring & Observability/Kubernetes Monitoring, Scale & Cloud

How do CloudWatch alarms work, including metric math and composite alarms?

IntermediateConceptKubernetes Monitoring, Scale & Cloud
Answer

An alarm watches one metric (or a metric math expression) and moves between OK, ALARM and INSUFFICIENT_DATA. Key settings: Period, EvaluationPeriods, DatapointsToAlarm (M out of N) and TreatMissingData (missing, notBreaching, breaching, ignore).

aws cloudwatch put-metric-alarm --alarm-name api-5xx \
  --namespace AWS/ApplicationELB --metric-name HTTPCode_Target_5XX_Count \
  --dimensions Name=LoadBalancer,Value=app/api/123abc \
  --statistic Sum --period 60 --evaluation-periods 5 --datapoints-to-alarm 3 \
  --threshold 50 --comparison-operator GreaterThanThreshold \
  --treat-missing-data notBreaching --alarm-actions arn:aws:sns:eu-west-1:111122223333:oncall
  • Metric math: alarm on expressions like an error ratio 100 * errors / requests.
  • Anomaly detection: alarm outside a learned band.
  • Composite alarms: combine alarms with AND/OR/NOT to page only when, for example, both 5xx and latency alarms fire, which cuts noise.
All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Kubernetes Monitoring, Scale & Cloud