Overview of RDS for MySQL database logs (original) (raw)

You can monitor the following types of RDS for MySQL log files:

The RDS for MySQL error log is generated by default. You can generate the slow query and general logs by setting parameters in your DB parameter group.

Topics

RDS for MySQL error logs

RDS for MySQL writes errors in themysql-error.log file. Each log file has the hour it was generated (in UTC) appended to its name. The log files also have a timestamp that helps you determine when the log entries were written.

RDS for MySQL writes to the error log only on startup, shutdown, and when it encounters errors. A DB instance can go hours or days without new entries being written to the error log. If you see no recent entries, it's because the server didn't encounter an error that would result in a log entry.

By design, the error logs are filtered so that only unexpected events such as errors are shown. However, the error logs also contain some additional database information, for example query progress, which isn't shown. Therefore, even without any actual errors the size of the error logs might increase because of ongoing database activities. And while you might see a certain size in bytes or kilobytes for the error logs in the AWS Management Console, they might have 0 bytes when you download them.

RDS for MySQL writesmysql-error.log to disk every 5 minutes. It appends the contents of the log tomysql-error-running.log.

RDS for MySQL rotates the mysql-error-running.log file every hour. It retains the logs generated during the last two weeks.

Note

The log retention period is different between Amazon RDS and Aurora.

RDS for MySQL slow query and general logs

You can write the RDS for MySQL slow query log and the general log to a file or a database table. To do so, set parameters in your DB parameter group. For information about creating and modifying a DB parameter group, see Parameter groups for Amazon RDS. You must set these parameters before you can view the slow query log or general log in the Amazon RDS console or by using the Amazon RDS API, Amazon RDS CLI, or AWS SDKs.

You can control RDS for MySQL logging by using the parameters in this list:

For slow query data to appear in Amazon CloudWatch Logs, the following conditions must be met:

For more information about the slow query and general logs, go to the following topics in the MySQL documentation:

MySQL audit log

To access the audit log, the DB instance must use a custom option group with theMARIADB_AUDIT_PLUGIN option. For more information, see MariaDB Audit Plugin support for MySQL.

Log rotation and retention for RDS for MySQL

When logging is enabled, Amazon RDS rotates table logs or deletes log files at regular intervals. This measure is a precaution to reduce the possibility of a large log file either blocking database use or affecting performance. RDS for MySQL handles rotation and deletion as follows:

To work with the logs from the Amazon RDS console, Amazon RDS API, Amazon RDS CLI, or AWS SDKs, set the log_output parameter to FILE. Like the MySQL error log, these log files are rotated hourly. The log files that were generated during the previous two weeks are retained. Note that the retention period is different between Amazon RDS and Aurora.

Size limits on redo logs

For RDS for MySQL version 8.0.32 and lower, the default value of this parameter is 256 MB. This amount is derived by multiplying the default value of theinnodb_log_file_size parameter (128 MB) by the default value of theinnodb_log_files_in_group parameter (2). For more information, seeBest practices for configuring parameters for Amazon RDS for MySQL, part 1: Parameters related to performance.

For RDS for MySQL version 8.0.33 and higher minor versions, Amazon RDS uses theinnodb_redo_log_capacity parameter instead of theinnodb_log_file_size parameter. The Amazon RDS default value of theinnodb_redo_log_capacity parameter is 2 GB. For more information, see Changes in MySQL 8.0.30 in the MySQL documentation.

Starting with MySQL 8.4, Amazon RDS enables the innodb_dedicated_server parameter by default. With the innodb_dedicated_server parameter, the database engine calculates the innodb_buffer_pool_size andinnodb_redo_log_capacity parameters. For more information, see Configuring buffer pool size and redo log capacity in MySQL 8.4.