How do I set up a CloudWatch alarm for high CPU usage on an EC2 instance?

0

How do I set up a CloudWatch alarm for high CPU usage on an EC2 instance? I want to monitor my EC2 instance and get notified if CPU usage goes above 80% for 5 minutes. Is there a quick way to do this in the AWS console?

Do I need to install an agent, or is it built-in?

1 Answer
1
Accepted Answer

You can set up a CloudWatch alarm for high CPU usage on an EC2 instance without installing any agent, as basic monitoring is built-in for EC2 instances.

Here's how to create a CPU usage alarm through the EC2 console:

  1. Open the Amazon EC2 console
  2. In the navigation pane, select "Instances"
  3. Select your instance and choose "Actions" > "Monitor and troubleshoot" > "Manage CloudWatch alarms"
  4. On the "Manage CloudWatch alarms" page, select "Create an alarm"
  5. For "Alarm notification", choose to configure Amazon SNS notifications. You can either select an existing SNS topic or create a new one by entering a name
  6. For "Alarm thresholds", configure:
  • Keep "Group samples by" as "Average"
  • Keep "Type of data to sample" as "CPU utilization"
  • Set "Alarm when" to ">=" and enter "0.80" for "Percent" (representing 80%)
  • Enter "1" for "Consecutive period" and select "5 minutes" for "Period"
  1. Optionally, you can add the metric data to your dashboard
  2. Choose "Create" to save the alarm

Alternatively, you can create the alarm through the CloudWatch console:

  1. Open the CloudWatch console
  2. Select "Alarms" and click "Create alarm"
  3. Choose the EC2 metric you want to monitor (select "EC2 > Per-Instance Metrics" and find your instance)
  4. Select the "CPUUtilization" metric
  5. Configure the alarm conditions:
  • Set statistic to "Average"
  • Set period to 5 minutes (300 seconds)
  • Set threshold type to "Static"
  • Set condition to "Greater than"
  • Set threshold value to 80
  • Configure evaluation periods
  1. Set up the SNS notification
  2. Give your alarm a name and description
  3. Review and create the alarm

AWS recommends monitoring CPU utilization with a threshold of 80% as a best practice, as consistently high utilization might indicate a resource bottleneck or application performance issues.
Sources
Create a CloudWatch alarm for an instance - Amazon Elastic Compute Cloud
You want to monitor your EC2 instances cpu usage and set up an alarm to trigger an SNS notification when usage exceeds 70%. | AWS re:Post
Recommended alarms - Amazon CloudWatch

answered 5 days ago
EXPERT
reviewed 5 days ago
AWS
MODERATOR
reviewed 5 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions