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/NOTto page only when, for example, both 5xx and latency alarms fire, which cuts noise.
More on Kubernetes Monitoring, Scale & Cloud
What is kube-prometheus-stack and what does it install?BeginnerWhat CRDs does the Prometheus Operator provide?IntermediateHow does the Prometheus Operator decide which ServiceMonitors to load?IntermediateWhich cAdvisor container memory metric should you watch, and why?IntermediateHow do metrics-server and the custom/external metrics APIs relate to HPA?IntermediateWhich kube-state-metrics metrics do you use most?Beginner