Amazon CloudWatch
User Guide

Create a CPU Usage Alarm that Sends Email

You can create an CloudWatch alarm that sends an email message using Amazon SNS when the alarm changes state from OK to ALARM.

The alarm changes to the ALARM state when the average CPU use of an EC2 instance exceeds a specified threshold for consecutive specified periods.

Set Up a CPU Usage Alarm Using the AWS Management Console

Use these steps to use the AWS Management Console to create a CPU usage alarm.

To create an alarm that sends email based on CPU usage

  1. Open the CloudWatch console at

  2. In the navigation pane, choose Alarms, Create Alarm.

  3. Under EC2 Metrics, choose a metric category (for example, Per-Instance Metrics).

  4. Select a metric as follows:

    1. Select a row with the instance and the CPUUtilization metric.

    2. For the statistic, choose Average, choose one of the predefined percentiles, or specify a custom percentile (for example, p95.45).

    3. Choose a period (for example, 5 minutes).

    4. Choose Next.

              CPUUtilization metric selected
  5. Define the alarm as follows:

    1. Under Alarm Threshold, type a unique name for the alarm (for example, myHighCpuAlarm) and a description of the alarm (for example, CPU usage exceeds 70 percent). Alarm names must contain only ASCII characters.

    2. Under Whenever, for is, choose > and type 70. For for, type 2. This specifies that the alarm is triggered if the CPU usage is above 70 percent for two consecutive sampling periods.

                  Alarm threshold specified
    3. Under Additional settings, for Treat missing data as, choose bad (breaching threshold), as missing data points may indicate that the instance is down.

    4. Under Actions, for Whenever this alarm, choose State is ALARM. For Send notification to, select an existing SNS topic or create a new one.

                  Alarm actions specified
    5. To create a new SNS topic, choose New list. For Send notification to, type a name for the SNS topic (for example, myHighCpuAlarm), and for Email list, type a comma-separated list of email addresses to be notified when the alarm changes to the ALARM state. Each email address is sent a topic subscription confirmation email. You must confirm the subscription before notifications can be sent.

    6. Choose Create Alarm.

Set Up a CPU Usage Alarm Using the AWS CLI

Use these steps to use the AWS CLI to create a CPU usage alarm.

To create an alarm that sends email based on CPU usage

  1. Set up an SNS topic. For more information, see Set Up Amazon SNS Notifications.

  2. Create an alarm using the put-metric-alarm command as follows.

    aws cloudwatch put-metric-alarm --alarm-name cpu-mon --alarm-description "Alarm when CPU exceeds 70%" --metric-name CPUUtilization --namespace AWS/EC2 --statistic Average --period 300 --threshold 70 --comparison-operator GreaterThanThreshold --dimensions Name=InstanceId,Value=i-12345678 --evaluation-periods 2 --alarm-actions arn:aws:sns:us-east-1:111122223333:my-topic --unit Percent
  3. Test the alarm by forcing an alarm state change using the set-alarm-state command.

    1. Change the alarm state from INSUFFICIENT_DATA to OK:

      aws cloudwatch set-alarm-state --alarm-name cpu-mon --state-reason "initializing" --state-value OK
    2. Change the alarm state from OK to ALARM:

      aws cloudwatch set-alarm-state --alarm-name cpu-mon --state-reason "initializing" --state-value ALARM
    3. Check that you have received an email notification about the alarm.