Skip to content

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.

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:

  1. Open the Aurora and RDS console.
  2. In the navigation pane, choose Parameter groups.
  3. 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.
  4. To view the logs on the Aurora and RDS console, set log_output to FILE.
  5. 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)

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

replied 2 years ago

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

AWS
EXPERT
replied 2 years ago