A metric alarm watches a single CloudWatch metric or the result of a math expression based on CloudWatch metrics. The alarm performs one or more actions based on the value of the metric or expression relative to a threshold over a number of time periods. The action can be an Amazon EC2 action, an Amazon EC2 Auto Scaling action, or a notification sent to an Amazon SNS topic.
Create alarm
Select metric
ContainerInsights
or ECS/ContainerInsights
namespaceClusterName
dimension and select one of the CPU Utilization metrics. If you see pod_cpu_utilization
, select that which will show your screen similar to the one belowSelect metric
which will take you to the screen as the one belowEnter the threshold value (for example, 50 which means 50% CPU utlization because this metric is a percent type) that you want the metric data to be monitored. Notice that Static
option is selected by default, which means we will be setting a static value as the threshold to be monitored.
Expand Additional configuration
where you can indicate how many occurences of the breach qualifies for the alarm to be triggered. Set the values to 2 out of 5, which will make the alarm get triggered if there has been 2 breaches in 5 evaluation periods. Notice the message at the top of the graph describing the setting as This alarm will trigger when the blue line goes above the red line for 2 datapoints within 25 minutes.
Click Next
In the Configure actions
screen, you can set what action you want to take when the alarm changes to different states such as
The available options for actions include, - Send a notification to an SNS topic - Take an Auto scaling action - EC2 action if the metric is from an EC2 instance
Select Create a new topic
to create a new SNS topic to send the notification to and provide your email address.
Create topic
to create the SNS topicNext
, give the alarm a name and click Next
again to review the configurationCreate
to create the alarmOnce you have created the alarm, you will notice that the alarm is now in Insufficient data
state which indicates that there is not enough data to validate the alarm. Waiting for 5 minutes will change the alarm state to OK
in green.
Click on the alarm to see the alarm details as shown below. Notice the alarm state now changed to ‘OK’ after evaluation was complete.