How to create Cloudwatch alarms for RDS (MySQL) on AWS
Monitoring your RDS instances is very important, and the same applies to other resources. In this article, we will create a simple alarm for an RDS MySQL instance which will check for free storage space on the instance. There are different metrics too which can be used to create alarms, click here to see the list of available metrics for RDS instances. The "FreeStorageSpace" metric checks for the storage space available on the instance and depending upon the condition specified the alarm gets triggered and sends notifications to SNS Endpoint. The "FreeStorageSpace" metric accepts the value in bytes and not percent.
Before we proceed with this article, I assume you are aware of the basics of RDS instances and already have one in your account to create alarms for.
Pre-requisites
- AWS Account (Create if you don’t have one).
- RDS MySql Instance to create an alarm for it.
What will we do?
- Login to AWS.
- Create an alarm for RDS MySql Instance.
- Delete the alarm.
Login to AWS
Click here to go to AWS Login Page.
You will see the login page as follows when you hit the above link. Enter your credentials to login into your AWS account.
Once you successfully login into your account you will see the AWS management console as follows.
Create an alarm for RDS MySql Instance
To create an alarm you need to first go to Cloudwatch. Search for cloud watch in the search box at the top.
You will see the main cloud watch dashboard as follows. Click on "Alarms" in the left panel.
Since there are no alarms in my account under the selected region we don't see anything on this page.
To create an alarm for the RDS instance you already have in your account, click on the "Create alarm" button.
On this page, click on the "Select metric" button.
In the search box type RDS and hit the enter button to filter the metrics for RDS. Click on "RDS - > Across All Databases" to go to the page where you will see metrics related to all your database instances available in the current region.
You can select any one of the metrics available in the list to create an alarm for it. Here, I have chosen the "FreeStorageSpace" metric. Click on the "Select metric" button to proceed.
Under Conditions, specify a threshold value for the metriC and select the "Lesser" option. The Alarm will get triggered if the free storage space for the RDS instance goes below the specified threshold value. Click on the "Next" button to proceed.
On this page, you can select an SNS topic from your existing topics or create a new one. If the alarm gets triggered it will send a notification to the selected SNS topic on the endpoint subscribed to the topic.
On the next page give a name to the alarm and add a description to it. Click on the "Next" button to proceed further.
Review all the configurations for the alarm and click on the "Create alarm" button.
Once the alarm gets created successfully you can see it on the Alarms Page. The current state of the alarm is "OK". It means the condition has not been satisfied and the free storage space on the RDS instance is still above the threshold value we specified in the alarm. If the storage space on the RDS instance goes below the threshold value we specified, the alarm will get triggered and a notification will be sent to the SNS Endpoint.
Delete the Alarm
When you no longer need the alarm you can delete it easily. Select the alarm to be deleted and click on the "Actions -- > Delete" button.
You will get a pop-up screen and then click on the "Delete" button which will permanently delete the alarm. Once the alarm is deleted you cannot restore it, so be careful while performing a delete operation on alarms.
Conclusion
In this article, we saw the steps to create an alarm for the RDS instance. We created an alarm that will get triggered if the free storage space on the RDS instance goes below the specified threshold value, we can choose the condition as per our requirement for the alarm. We also saw how an alarm can be easily deleted in just a few clicks.