Archive · AWS

CloudWatch Metrics and Alarms

What EC2 reports by default, what it does not, and how to alarm on CPU.

1 min read

  • Amazon CloudWatch
  • Amazon EC2
  • Amazon SNS

CloudWatch collects metrics from AWS services automatically. EC2 reports CPU, network and disk I/O every 5 minutes; enabling detailed monitoring gives 1-minute data at extra cost.

EC2 does not report memory or filesystem usage, because those are visible only inside the operating system. A later post covers the agent that fills that gap.

Create a CPU alarm and send it to an SNS topic you have subscribed your email to:

aws sns create-topic --name ops-alerts
aws sns subscribe --topic-arn <arn> --protocol email --notification-endpoint you@example.com

aws cloudwatch put-metric-alarm --alarm-name web1-cpu-high \
  --namespace AWS/EC2 --metric-name CPUUtilization \
  --dimensions Name=InstanceId,Value=i-0abc123 \
  --statistic Average --period 300 --evaluation-periods 2 \
  --threshold 80 --comparison-operator GreaterThanThreshold \
  --alarm-actions <topic-arn>

Require two evaluation periods so a single spike does not page anyone. Also alarm on StatusCheckFailed, which catches hung instances.