AWS › Monitoring (CloudWatch)
How do CloudWatch alarms work, and what actions can they automatically trigger when a threshold is breached?
BeginnerAnswer
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:AlertTopicReal-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.