AWS › Monitoring (CloudWatch)

How do CloudWatch alarms work, and what actions can they automatically trigger when a threshold is breached?

Beginner

Answer

A CloudWatch alarm continuously monitors a specific metric against a threshold you define, and when that threshold is breached for a specified number of consecutive evaluation periods, the alarm changes state and can automatically trigger actions such as sending a notification through SNS, triggering an Auto Scaling action to add or remove capacity, or invoking a Lambda function to perform custom remediation logic.
aws cloudwatch put-metric-alarm --alarm-name high-cpu-alarm --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 80 --comparison-operator GreaterThanThreshold --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:123456789012:AlertTopic
Real-world example An operations team sets up a CloudWatch alarm that automatically sends an SNS notification to the on call engineer whenever a critical service's average CPU utilization exceeds eighty percent for two consecutive five minute periods.

Common follow-ups: What is the difference between an alarm's ALARM, OK, and INSUFFICIENT_DATA states?;How do you avoid alarms triggering too frequently due to normal, brief metric fluctuations?