I want to activate and monitor logs for an Amazon Relational Database Service (Amazon RDS) for MySQL DB instance.
Short description
Note: If you receive errors when you run AWS Command Line Interface (AWS CLI) commands, then see Troubleshoot AWS CLI errors. Also, make sure that you're using the most recent AWS CLI version.
To monitor the Amazon RDS for MySQL error log, slow query log, and the general log, use the Amazon RDS console, Amazon RDS API, Amazon RDS CLI, or AWS SDKs. By default, the MySQL error log file is automatically generated. You can generate the slow query log and the general log.
Resolution
Modify a DB parameter group
Note: You can't modify a default DB parameter group. You can modify only a custom DB parameter if Is modifiable is set to true.
To modify a DB parameter group that's associated with your Amazon RDS for MySQL instance, complete the following steps:
- (Optional) If you don't have a DB parameter group, then Create a new DB parameter group.
- Modify the required parameters of your DB parameter group:
Choose Edit parameters.
Set General log to 1.
Set Slow query log to 1.
Set Long query time to 2.
Note: General log, Slow query log, and Long query time parameters are dynamic and don't require a system reboot.
- To view the logs from the Amazon RDS console, set log output to FILE.
- To view the logs from a SQL query, set log output to TABLE.
- (Optional) If you created a new DB parameter group, then Associate the DB parameter group to your Amazon RDS for MySQL instance.
Note: The parameter group name changes apply immediately, but parameter group changes aren't applied until you manually reboot the instance. There's a momentary outage when you reboot a DB instance and the instance status shows that it's rebooting.
View logs
If the log_output parameter is set to TABLE, then query the log tables:
Select * from mysql.slow_log;
Select * from mysql.general_log;
Note: When you turn on table logging, the database performance for high throughput workload might decrease. For more information, see Managing table-based MySQL logs.
If the log_output parameter is set to FILE, then use the Amazon RDS console to view the database log files for your DB engine.
Note: Error logs are stored as files and aren't affected by the log_output parameter.
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)