Description:

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

Cloudwatch

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

Cloudwatch

If you search for log_output, By default log_output = TABLE

Cloudwatch

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

Cloudwatch

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

Cloudwatch

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.

Cloudwatch

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

Cloudwatch

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.

Cloudwatch

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

Note: If 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

RDS CONSOLE

2)Choose Database from the navigation pane

Cloudwatch

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

Cloudwatch
Cloudwatch

If you scroll down you should see Log Exports

Cloudwatch

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.

Cloudwatch

5)Then Continue and choose Modify DB Instance

Cloudwatch

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
CLOUDWATCH CONSOLE

Choose Log groups under Logs section

Cloudwatch

You can find the Log group created by RDS Instance.

Cloudwatch

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.

Cloudwatch

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

I believe that this article helped you a lot. Check these ,