In the previous articles , I have explained , How you can

Monitor and auto-recover repaired EC2 instances

Monitor AWS resources using Cloudwatch Alarms

In this guide , We will learn How we can monitor the RDS instances using Cloudwatch.

By default , RDS instance send metrics to the Cloudwatch Metrics.

Using the cloudwatch metrics , We can monitor the RDS instances for parameters such as Read IOPS , Write IOPS , Free Storage , CPU utilization.

Monitoring RDS Instances

As said earlier , We are going to setup monitoring for

  • CPU utilization
  • Free Storage
  • Read IOPS
  • Write IOPS

To create cloudwatch alarms , Login to Cloudwatch console.

In the left navigation pane , Choose Metrics

RDS

From the lists of available metrics , Choose RDS

RDS

You can check the metrics of the RDS DB instance by

  • Per-Database Metrics
  • By Database class
  • By Database Engine
  • Across All Databases
RDS

For example , If you want to check the metrics for particular DB instance , Choose Per-Database Metrics

There you can find the List of the databases and their respective metric name such as Free Memory , Freestoragespace , WriteIOPS , ReadIOPS etc.

If you select the particular DBInstanceIdentifier and their Metric name

A graph will be plotted for the DB instance with the metrics.

RDS

If you want to check the metrics for a particular time duration , You can adjust it.

Now using these metrics lets setup a alarm , So that when a DB instance metric cross a threshold we set , For example , CPU usage is above 70/100 (in Percentage), Trigger the cloudwatch alarm and alert it to the medium (email or SMS).

Services Used for Monitoring and Alerting

  • Cloudwatch Alarms
  • SNS Topic with Subscriber

Creating Cloudwatch Alarms

Lets go ahead and create a Cloudwatch alarm for

CPU Utilization

Login to Cloudwatch console , In the left pane , Choose Alarms

RDS

Then Click Create alarm

RDS

Under Specify metric and conditions , Click Select metric

From the lists of available metrics , Choose RDS

and then click Per-Database Metrics

Select the DBInstanceIdentifier with the Metric Name CPUUtilization

Then choose Select metric

Under statistic Choose Minimum and Under Period Choose 1 minute

RDS

and Under Conditions

Threshold type should be static and whenever CPUUtillization is

Greater/Equal to 70 percent

RDS

Which means when the metric value goes above the threshold (70 percent) for 1 datapoint within 1 minute , The cloudwatch alarm will be triggered and will alert us.

Click Next , Here we are going to setup alerting for two cases.

  • If the metric value goes above the threshold (In alarm)
  • If the metric value goes below the threshold (OK)

Here we have to either use an existing SNS topic or We can create a new topic.

If you want to setup a SNS topic with a subscribers , Refer here

Once the SNS setup is completed , You can resume with the Notifications.

Or if you want to create SNS topic from cloudwatch console , Select Create new topic

Provide a name for the SNS topic and add the email addresses (who should receive the notifications) and then click Create topic

RDS

Once it is created , You should see as shown below.

RDS

We have now added for In alarm notification.

To get notifications for OK status , Choose Add notification and then select OK and select existing topic and we already have created a topic with a subscriber.

and then click Next

Provide a name for the alarm , For better identification , provide a name as follows,

Environment-DBname-Metricname

RDS

You can also add a short description for each alarm you create.

Click Next and then Choose Create Alarm.

Read IOPS

Lets create a alarm for Read IOPS.

We are going to following the same procedure , The only place that need modification is Specify metric and conditions

Here we are going to choose ReadIOPS

Under Conditions , For static threshold , Lets say your DB usually gets a ReadIOPS count of 150 , and anything above 150 should be considered as anomaly.

RDS

Click Next and Setup notifications for In alarm and OK state as discussed above.

You can use the same SNS topic.

Provide a name for the alarm and then click Create alarm

Write IOPS

Lets create a alarm for Write IOPS.

We are going to following the same procedure , The only place that need modification is Specify metric and conditions

Here we are going to choose WriteIOPS

Under Conditions , For static threshold , Lets say your DB usually gets a WriteIOPS count of 250 , and anything above 300 should be considered as anomaly.

RDS

Click Next and Setup notifications for In alarm and OK state as discussed above.

You can use the same SNS topic.

Provide a name for the alarm and then click Create alarm

Free Storage Space

Lets create a alarm for Free storage space

We are going to following the same procedure , The only place that need modification is Specify metric and conditions

Here we are going to choose FreeStorageSpace

Under Conditions , For static threshold , Lets say , The RDS DB instance has the storage size of 200 GB in total and If the free storage size goes less than 25 GB , It should trigger the alarm and alert us.

and while giving the threshold value , 25 GB should be converted into bytes.

Whenever FreeStorageSpace is Lower/Equal to 25 GB.

RDS

Click Next and Setup notifications for In alarm and OK state as discussed above.

You can use the same SNS topic.

Provide a name for the alarm and then click Create alarm.

Conclusion

We have successfully implemented a monitoring and alerting mechanism using Cloudwatch alarm and SNS topic.

Hope you find it helpful. Thanks for reading this article.

Please check my other articles.