How do I activate and monitor logs for an Amazon RDS for MySQL DB instance?

3 minute read
0

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:

  1. (Optional) If you don't have a DB parameter group, then Create a new DB parameter group.
  2. 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.
  3. To view the logs from the Amazon RDS console, set log output to FILE.
  4. To view the logs from a SQL query, set log output to TABLE.
  5. (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)

2 Comments

long_query_time not found on MariaDB 10.11 family

The long_query_time parameter is not available on the MariaDB 10.11 parameter groups on the RDS console. Could this still be adjustable using the CLI? Thanks

Philip
replied 8 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 8 months ago