Using Cloudwatch Alarms Monitor AWS Resources

What is Cloudwatch?

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?

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:

  • 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:

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

Creating Cloudwatch Alarm:

To create a Cloudwatch alarm, Open the Cloudwatch Console,

In the left navigation panel, Choose Alarms

Click Create Alarm,

SPECIFY METRIC & CONDITIONS

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

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.

--

--

DevOps/Cloud | 2x AWS Certified | Terraform | Gitlab

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