High CPU on a server often goes unnoticed until users complain. Here is the fastest way to get an email the moment it happens, tested end to end on a real instance.
The flow: EC2 → CloudWatch alarm → SNS topic → your inbox
What you need
- An AWS account and an email address you can open
- One region for everything (I used US East, N. Virginia)
Setup in 4 steps
1. Launch an EC2 instance
Choose Amazon Linux and the t3.micro instance type. Give it any name.
2. Create the CloudWatch alarm
Select the instance, then go to Actions > Monitor and troubleshoot > Manage CloudWatch alarms. Create a new SNS topic and use these settings:
| Setting | Value |
|---|---|
| Statistic | Average |
| Metric | CPU utilization |
| Alarm when |
>= 40% |
| Period | 5 minutes, 1 consecutive |
3. Subscribe your email
Open SNS > Topics, select your topic and click Create subscription. Choose Email, enter your address, then click Confirm subscription in the email AWS sends you.
Important: no confirmation means no alerts.
4. Trigger the alarm
Connect to the instance and generate CPU load:
sudo su
yum install stress -y
stress --cpu 9 --timeout 600
The --timeout 600 stops the test after 10 minutes. You can also press Ctrl+C.
My result
CPU rose to about 50.9%. A few minutes later, this email arrived:
- State change: OK → ALARM
- Reason: a datapoint of about 50.94 was greater than or equal to the 40% threshold
- Link: straight to the alarm in the console
That is exactly the early warning I wanted.
Tip: 40% is for a demo. In production, use 70 to 80% over several periods to avoid noisy alerts.
Clean up
Stop stress, delete the alarm, delete the SNS topic and subscription, then terminate the instance.
Project Documentation
Full slides with screenshots and results:
Find Me Online
https://www.linkedin.com/in/vishalpatil-devops-aws/
dev.to
https://dev.to/vishal_patil_aws
Top comments (0)