I want to activate and monitor logs for an Amazon Relational Database Service (Amazon RDS) for MySQL DB instance.
Resolution
For a list of RDS for MySQL log files that you can monitor, see Overview of RDS for MySQL database logs. By default, Amazon RDS automatically generates error log files. To generate slow query logs and general logs, modify the parameters in your custom DB parameter group.
Modify your custom parameter group
If you don't have a custom parameter group, then create one. After you create the parameter group, associate it with your DB instance.
To modify your parameter group, complete the following steps:
- Open the Aurora and RDS console.
- In the navigation pane, choose Parameter groups.
- Select your custom parameter group, and then set the following parameters:
General_log to 1.
Slow_query_log to 1.
Long_query_time to 2.
Note: Because the preceding parameters are dynamic, you don't need to reboot the DB instance for the settings to take effect.
- To view the logs on the Aurora and RDS console, set log_output to FILE.
- To view the logs in a log table, set log_output to TABLE.
Note: When you turn on table logging, database performance might decrease and cause high throughput workloads. For more information, see Sending MySQL log output to tables.
View logs
If you set the log_output parameter to TABLE, then run the following queries to view the logs:
Select * from mysql.slow_log;
Select * from mysql.general_log;
If you set the log_output parameter to FILE, then use the Amazon Aurora and RDS console, AWS CLI, or RDS API to view the logs.
Note: You can view the error logs in the mysql-error.log file.
Monitor logs
To monitor logs, use the following methods:
Related information
Build proactive database monitoring for Amazon RDS with Amazon CloudWatch Logs, AWS Lambda, and Amazon Simple Notification Service (Amazon SNS)