Using Cloudwatch Alarms Monitor AWS Resources

What is Cloudwatch?

Cloudwatch is a monitoring and logging service in aws which helps us to monitor our aws resources in the form of logs and metrics.

We can use cloud watch to collect metrics of the applications and services we are running in real-time.

It also helps us to store the server and application logs.

By default, Amazon Cloudwatch services collect metrics from each aws resource If required you can enable detailed monitoring as well.

In this article, We will see how we can monitor and alert for aws resources based on the metrics and threshold we configure in the cloud watch alarm.

What is Cloudwatch Alarm?

Cloudwatch alarm is used to monitor a single cloud watch metric or the result of Match expression using cloud watch metrics.

Also, it sends out a notification based on the threshold we set for each service in the cloud watch alarm.

You can actively monitor the status of each alarm in the cloud watch dashboard.

States of Cloudwatch Alarms:

There are 3 states in the cloud watch alarms:

  • OK — The metric is below the threshold.
  • ALARM — When the metric crosses the threshold.
  • INSUFFICIENT_DATA — Not enough data available for the metric to determine the alarm state.

Prerequisites:

We need an SNS Topic with a Subscriber for the Cloudwatch alarm to alert us based on the alarm configuration

Once you have set up the SNS topic and the subscriber, let's go ahead and create a Cloudwatch alarm.

Creating Cloudwatch Alarm:

We have to choose the metric of the aws resources for the cloud watch alarm to monitor and the threshold configured for that metric.

To create a Cloudwatch alarm, Open the ,

In the left navigation panel, Choose Alarms

Click Create Alarm,

SPECIFY METRIC & CONDITIONS

Here we need to select the AWS resource, For example, EC2 and the Metric, For example, CPU Utilization.

Click Select metric,

Under Metrics, Select EC2, For this tutorial, We monitor EC2 Metrics using Cloudwatch alarm.

And then click Per-Instance Metrics

On the Next Page, Choose the EC2 Instance and the Metric name You want to Monitor.

And click Select Metric,

On the next page, You can find the details such as Metric name, namespace, InstanceId, and Instance name which you have chosen on the previous page.

Statistics are the data collected over a specific period of time. And these data made using the Metric name, namespace, dimensions, datapoint unit of measure.

We choose Minimum statistics for the period of 1 minute.

Under Conditions,

The threshold type can be Static or Dynamic.

Let's set up a Static threshold, When the CPU utilization is greater than or equal to 70 percent.

Click Next,

NOTIFICATION

When the cloud watch alarm turns to ALARM state, We will use the SNS topic to alert us.

Whenever this alarm state is, In Alarm

Select an SNS topic Which you have created.

If you want to get the alert when the metric value goes below a threshold.

Click Add new notification, Select OK, and the SNS topic which we have created.

Click Next, Provide a name for the Alarm, Click Next.

Choose to Create Alarm.

Now that we have created an alarm to monitor the CPU Utilization of the EC2 Instance based on the metrics and an alert based on the threshold using SNS topic.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store