Publish RDS MySQL Logs To Cloudwatch


To view Amazon RDS logs such as slow-query, General , Error & Audit logs in Cloudwatch, You must enable logging in the DB Instances.Then you should configure log exports on RDS instances to send logs to cloudwatch.

How To Do:

Each MySQL RDS instances should be associated with DB parameter group.You should enable slow_query_log and general_log in the parameter group for the instance to be able to send logs to Cloudwatch.

Sending Logs To Cloudwatch:

To send logs to cloudwatch, Configure log exports on the DB instances and set the log_output to FILE.

To configure log_output, choose the RDS instance, then choose Configuration

If you scroll down You will find the Parameter group associated with that RDS instance. Click that

If you search for log_output, By default log_output = TABLE

Choose log_output and Edit parameters and choose FILE and Save changes.

Doing this you will face an issue, That you cannot modify default parameter group.

So Create a new parameter group, Modify the instance and replace with the DB parameter group you have created.

Now you should be able to change the required DB parameters.

To Create A Parameter Group:

Choose Parameter groups from the left, Click Create parameter group

Choose the Db engine you are using, Give a name to the Parameter group and then choose Create.

Now Go to Database, Click modify , Scroll down to DB Parameter group, Replace with the one you have created, Continue and Apply the changes.

This requires an DB Instance Reboot,

So It better to perform these operations during Non-Production hours.

Choose Actions and Reboot. Now you are good to go.

Make sure Parameter group is in-sync.

Configuration Changes required to send slow_query_log & general_log to Cloudwatch

log_output = FILE
slow_query_log = 1
general_log = 1

NoteIf you set the log_output to TABLE, the logs will be stored in the table in mysql database of the RDS Instance.

To Configure Log Exports:

1)Open the AWS RDS console


2)Choose Database from the navigation pane

3)Select the instance for which you want to send logs to Cloudwatch and then choose Modify

If you scroll down you should see Log Exports

4)From the log exports section, Choose the types of logs you want to send to Cloudwatch

For example, I want to send all the logs to cloudwatch.

5)Then Continue and choose Modify DB Instance

Now You can observer that your RDS instance is configuring-log-exports to Cloudwatch.

Note: This activity doesn’t need any downtime

Verify The Logs In Cloudwatch:

Open AWS Cloudwatch Console

Choose Log groups under Logs section

You can find the Log group created by RDS Instance.

If you click the Log group, You will find the Log stream which collects are stores all the date from RDS Instances.

Now you find all the useful informations about RDS instance based on the Log exports you have configured.

Thus We have successfully Configured Log exports for RDS Instance to send logs to Cloudwatch.

I believe that this article helped you a lotCheck these ,