You may want to be warned when your account balance is over a certain amount.
Or, you want to know if one of your EC2 instance uses too much cpu.
Or, when using T2 instance, you don’t want to run out of CPU Credits.
And, for many other reasons, you need to create AWS Cloudwatch Alerts.
I’ll show you how to create 2 alerts to track your cpu usage and cpu credits on your EC2 T2 instances.
First, open the Cloudwatch console.
- Select the “Alarm” section on the left.
- Click “Create Alarm” button.
- On the “search Metrics” box, type “CPU”
- You will see all your instances, with corresponding metric you can watch, related to cpu.
- On the desired instance, check CPUUtilization, then click Next.
- On the “Define Alarm” section, choose a limit, e.g.
- Whenever CPUUtilization
is >= 25
for 2 periods- Periods lengths are defined on the right side, 2 periods of 5 minutes represents 10 minutes.
- So, if the average cpu is over 25, for 2 consecutive blocs of 5 minutes, the alarm will raise.
- Whenever CPUUtilization
- Next, add 2 notifications.
- You want an email when this alarm is entering its “alarm” state.
- But, you also want a notification when everything is back to normal. So, hit “+Notification” Button, and add another alarm, but choose “State is OK”.
Finally, do the same again, for “CPUCreditBalance” instead of “CPUUtilization”.
And, configure to get alarm when your Credit is below a fixed limit.
Something between 50 and 100 can be OK for a T2.Micro instance, but you can choose another limit based on the Alarm Preview graph.