This week I will explain Amazon Web Services RDS log files. RDS enables us to view, download, watch, query and binary of our db instances log files. I will demonstrate how to check our logs using MySQL RDS instance. There are some options we have to know before we proceed with our demo. By default , AWS generates error logs. If we need to see slow query and general log files, we have to set them in our database parameter group. RDS rotates all log files every hour and deletes the files older than 24 hours. In my demo, I will show how to view the error.log and enable slow query via console.
If I go to RDS console and click the Events or Logs button, I can see the recent events and the error.log of my db instance.
Since I didn’t enable slow query log or general log , there is only error.log there. There are three options to access the error.log. I can view, watch or download the log file. Let’s see how it works.
MySQL writes to the error log only on startup, shutdown, and when it encounters errors. So this is why my error.log is empty.
Here you can see a MSSQL error log file:
Now I will configure slow query log on my MySQL instance. First of all, I create a new paramater group.
Then I select it and edit parameters. I search for “slow_query_log” , change the “engine-default” to “1” and save the parameter group.
If I select my parameter group and click “Compare paramaters” , I can see the differences with the default parameter group.
Here I want to inform that there are options for log output. If you check the log_output parameter , you can see that it can be “Table” or “File”. By default logs are written to a table and in my example I leave it as default. I also add that AWS doesn’t allow to truncate the log tables. But you can move their contents. If you want to read more about it please visit here.
Our last step is modifying our instance. I select “Modify” from “Instance Actions” and change the DB parameter group.I also enable apply immediately ( you can wait for next scheduled maintenance time )
After it applies, it will show as “pending-reboot”. Since this is my demo environment, I reboot it asap :). After reboot, it will show that our new parameter group is “in-sync”.
Ok we are back again. Now let’s see our log dashboard.
As you see we have now “slowquery/mysql-slowquery.log” in action. Also there are entries in error.log since we rebooted our instance. Let’s see the entries.
Now we are able to monitor our database and fine tune our queries using slow_query_log. If you want to disable slow query logs again, you can change the parameter or revert to the default parameter group. I think that’s easy to configure and helpful.
If you have any question or comment, please feel free to write and don’t forget to share please.