Create Alarm
You can create a CloudWatch alarm that monitors CloudWatch metrics for a given AWS service. CloudWatch will automatically send you a notification when the metric reaches a threshold you specify.
In this section you will create an alarm that monitors the amount of traffic received by an EC2 instance and sends an email notification if a threshold is breached.
-
In the CloudWatch console navigate to All alarms and click on Create alarm
-
Click Select metric
-
Click on EC2
-
Click on Per-instance Metrics
-
Enter
NetworkIn
in the search box and hit enter. -
Select the checkbox for
VPC B Private AZ1 Server
and click Select metric -
In the resulting Specify metric and conditions screen change the Statistic and Period fields to
Maximum
and1 minute
respectively. -
In the Conditions section below, enter a threshold value of
1000000
and click Next -
In the Configure actions screen click on Add notification
-
Select Create new topic, enter
NetworkingWorkshopAlarmTopic
as the name, enter your email and click Create topic -
Scroll to the bottom of the page, click Next and on the resulting screen
- Enter
NetworkingWorkshopAlarm
as the Alarm name - Click Next
- Enter
-
Review the values on the Preview and create screen and click Create alarm
-
The alarm will be created but the "State" of the alarm may show "Insufficient data". This will happen until enough data points are received by the alarm.
-
Under Actions there will be a warning for "Pending confirmation" which means that you have not confirmed the email subscription to SNS yet.
-
Go into your email, open the new message from "AWS Notifications" and confirm the subscription. This will be required to ensure you receive the notification.
In the next section you will get the opportunity to trigger the alarm and test the notification that you configured.