• Home
  • AWS
  • Creating a CloudWatch Alarm in AWS

Creating a CloudWatch Alarm in AWS

  • (5.0)
  • | 4893 Ratings

Create a CloudWatch Alarm

You can create a CloudWatch alarm that sends a simple notification service message when the alarm changes the state. Alarm watches every single metric over a time period and hence performs actions depending on those metric values. Moreover, Amazon CloudWatch is a web service that enables you to monitor, manage, and publish various metrics and to configure alarm actions based on those metrics. With Amazon CloudWatch, you can collect, analyze, and view system and application metrics so that you can make operational and business decisions instantly and confidently. Amazon CloudWatch automatically collects metrics about your AWS resources, such as the performance of your Amazon EC2 instances. You can publish your own metrics directly to Amazon CloudWatch.

After an alarm invokes an action due to a change in the state, its subsequent behavior depends on the type of action that you have associated with the alarm. For Auto Scaling policy notifications, the alarm continues to invoke the action for every period that the alarm remains in the new state. For Amazon Simple Notification Service notifications, no additional actions are invoked.

You can use Amazon CloudWatch to diagnose problems by looking at system performance before and after a problem occurs. Amazon CloudWatch helps you identify the cause and verify your fix by tracking performance in real time. For example, you can set up Amazon CloudWatch to send you an email right away when your application slows down, so you can go back and discover, that a particular database was being overloaded. When you have fixed the problem, you can use Amazon CloudWatch to watch response times return to normal. For more information about creating CloudWatch alarms, go to Creating CloudWatch Alarms in the Amazon CloudWatch Developer Guide.

A common use for Amazon CloudWatch is to keep your applications and services healthy and running efficiently. For example, you can use it to discover that your website runs best when network traffic to your Amazon EC2 instances remains below a certain threshold. You can then create an Auto Scaling policy to ensure that you always have the right number of instances to match the amount of traffic you have.

Amazon CloudWatch can monitor AWS resources such as Amazon EC2 instances, Amazon Dyanamo DB tables and Amazon RDS DB instances.

In the previous task, we have created an Auto Scaling policy to add to the number of running instances. In this task, we’ll associate that policy with an alarm action. When the alarm is triggered, Auto Scaling is notified and makes the appropriate changes to your resources.

An alarm has three feasible states:

  • OK – which means the metric is within the threshold limit
  • ALARM- means metric has gone outside the defined threshold limit
  • INSUFFICIENT_DATA- means enough data is not available for the metric to determine the alarm state

You’ll create an alarm with the following characteristics:


The following diagram demonstrates how Amazon CloudWatch and Auto Scaling would work together. The Amazon EC2 instance, reports its Network Out metric to Amazon CloudWatch. Amazon CloudWatch fires an alarm if the specified threshold has exceeded and reports this to the Auto Scaling Group. The Auto Scaling group then takes action based on the policy that was set.

Amazon CloudWatch

This topic walks you through creating a CloudWatch alarm to alert the application when the threshold is exceeded. To save time, we’ll create just one alarm; however, you can apply the same procedure to create other alarms. For example, you could create another alarm to notify Auto Scaling, that it needs to terminate at an instance. For more information about Amazon CloudWatch, see the Amazon CloudWatch details page.

Checkout Amazon EC2 Interview Questions

To create an Amazon CloudWatch alarm

You can create an alarm from the Alarms list in the Amazon CloudWatch console.

1. Select a metric for your alarm:

  • Open the Amazon CloudWatch console at https:// cloudwatch/.
  • In the Navigation pane, in the Region list, click US East (Virginia). Click Alarms.
  • In the details pane, click Create Alarm.
  • In the Create Alarm Wizard, click on the Select Metric page, in the Viewing list, select EC2: Aggregated by Auto Scaling Group.

Create Alarm Wizard

  • Click the MyAutoScalingGroup/Network Out row, and then click Continue.

Note: It might take up to 15 minutes for the Auto Scaling group to appear in the list. If you do not see your Auto Scaling group, wait up to 15 minutes, and then try again.

2. Define the alarm:

On the Define Alarm page of the Create Alarm wizard, do the following, and then click Continue:

  • In the Name box, type MyNetworkOutAlarm.
  • In the description box, type a description.
  • In the Define Alarm Threshold section, click > =, type 6000000 in the first box and 5 in the minutes box. For your own application, you can do some load testing to see what values make the most sense.


3. Define your actions:

a) On the Configure Actions page of the Create Alarm wizard, do the following, and then click Add Action.

  • Under When Alarm state , click ALARM.
  • Under the Take Action list, click Auto Scaling Policy.
  • In the Auto Scaling Group list, click MyAutoScalingGroup.
  • Click on the Policy list

Checkout AWS IoT Tutorial

b) Do the following, and then click Continue.

  • In the new row that has been created, under When Alarm state , click ALARM.
  • Under the Take Action list, click Send Notification.
  • In the Topic box, type a topic name.
  • In the email(s) box, type an email address to where notification has to be sent.

Click Send Notification

4. On the review page, review the settings. If everything is all right, click ‘Create Alarm’.

Create Alarm

5. On the confirmation page, click close.

Click close

On the dashboard page of the Amazon CloudWatch console, your new alarm now appears in the list.

Amazon CloudWatch console

If you create a MyScaleDownPolicy, you can create another alarm using the same steps.

Where You’re At

Here’s where you are building your architecture.


Congratulations! You have successfully deployed your web application to EC2 by using some of the essential building blocks of AWS. To verify that everything is working as it should, do the following:

  • Refresh your browser. You should no longer be able to access your website, because you updated your security group to allow access only through your Elastic Load Balancer.
  • Type the public DNS address of your Elastic Load Balancer which you have recorded in Step 7. Create an Elastic Load Balancer, to verify if you can see your application.
  • Public DNS address

In this tutorial, you have learnt how to deploy your web application by using the following AWS products:

  • Amazon EC2 to run your application
  • Elastic Load Balancing to load balance traffic across your running instances
  • Auto Scaling to automatically add and terminate instances according to the policies that you set.
  • Amazon CloudWatch to monitor your instances and to notify you when the thresholds you have specified had exceeded

Explore AWS Sample Resumes! Download & Edit, Get Noticed by Top Employers!Download Now!

When you have a better understanding of the AWS services and how you want to use them, there is an easier way you can deploy your application. AWS Cloud Formation helps you deploy resources in AWS without worrying about the order in which AWS services need to be provisioned or the subtleties of how to make those dependencies work. To learn how to build a sample template using the services we used in this tutorial, go to Auto Scaling Group with LoadBalancer, Auto Scaling Policies, and CloudWatch Alarms in the AWS Cloud Formation User Guide. If you are finished using your AWS resources, you can terminate them so that you are no longer billed. Move on to further post titled ‘Clean Up‘.

[Related Pages: AWS Tutorial]

List Of AWS Courses Offered By Mindmajix:

Subscribe For Free Demo

Free Demo for Corporate & Online Trainings.

About The Author

Prasanthi is an expert writer in MongoDB, and has written for various reputable online and print publications. At present, she is working for Mindmajix, and writes content not only on MongoDB, but also on Sharepoint, Uipath, and AWS. Protection Status