Skip to content

How do I view and download logs for an Aurora Serverless DB cluster?

3 minute read
0

I want to view and download logs to audit database activity for my Amazon Aurora Serverless DB clusters that run Amazon Aurora MySQL-Compatible Edition or Amazon Aurora PostgreSQL-Compatible Edition.

Short description

For Aurora MySQL-Compatible DB clusters, activate the general log and slow query log. For Aurora PostgreSQL-Compatible DB clusters, use the log_statement parameter to control logs.

To view and download the logs, you must use Amazon CloudWatch. You can't view the logs directly from the Amazon Relational Database Service (Amazon RDS) console. Aurora Serverless connects to a proxy fleet of DB instances that automatically scales. There isn't a direct DB instance to access and host log files.

Resolution

Activate logs for Aurora Serverless

To activate logs on Aurora Serverless, modify the custom DB cluster parameter group or the DB instance parameter group.

Complete the following steps:

  1. Create a custom DB cluster parameter group. Or, use the DB cluster's existing custom DB cluster parameter group.
  2. Modify the DB cluster parameter group values based on your DB cluster type:
    For MySQL DB clusters, Aurora activates the error log by default. To activate the general log and slow query log, set general_log to 1 and slow_query_log to 1.
    For PostgreSQL DB clusters, use the log_statement parameter to determine the SQL statements that Aurora logs. The default value is none. To log the query and error logs, change the value to all.
    -or-
    Modify your DB instance parameter group. When you use an instance parameter and set Source to Modified, Aurora ignores the parameter set on the cluster parameter group.
  3. Modify your DB cluster to use the custom DB cluster parameter group.
  4. Open the Aurora and Amazon RDS console, and then use the Log exports settings to choose the logs to upload to CloudWatch.

Note: If you need to resolve issues in your DB instance, then it's a best practice to set log_statement to all to log all statements. To log all data definition language (DDL) statements such as CREATE, ALTER, and DROP, set the parameter value to ddl. To log all DDL and data modification language (DML) statements such as INSERT, UPDATE, and DELETE, set the parameter value to mod.

View the logs in CloudWatch

After you activate log exports, Aurora Serverless publishes the logs to CloudWatch.

To view and download the logs, complete the following steps:

  1. Open the CloudWatch console.
  2. In the navigation pane, choose Log groups.
  3. Find the log group for your DB cluster. Each log type publishes to a separate log group named /aws/rds/cluster/cluster-name/log-type. For example, /aws/rds/cluster/my-cluster/slowquery.
  4. Select the log group to view the log events.
  5. To download the log data, export the logs to an Amazon Simple Storage Service (Amazon S3) bucket.

For more information, see Monitoring log events in Amazon CloudWatch.

Related information

How do I turn on audit logging for my Amazon Aurora MySQL DB cluster and publish the logs to CloudWatch?

How do I publish logs for Amazon RDS for MySQL or Amazon Aurora MySQL instances to CloudWatch?

Working with RDS and Aurora PostgreSQL logs: Part 1