Amazon RDS for Db2 database log files
You can access RDS for Db2 diagnostic logs and notify logs by using the Amazon RDS console, AWS CLI, or RDS API. For more information about viewing, downloading, and watching file-based database logs, see Monitoring Amazon RDS log files.
Retention schedule
Log files are rotated each day and whenever your DB instance is restarted. The following is the retention schedule for RDS for Db2 logs on Amazon RDS.
Log type | Retention schedule |
---|---|
Diagnostic logs |
Db2 deletes logs outside of the retention settings in the
instance-level configuration. Amazon RDS sets the |
Notify logs |
Db2 deletes logs outside of the retention settings in the
instance-level configuration. Amazon RDS sets the |
Publishing Db2 logs to Amazon CloudWatch Logs
With RDS for Db2, you can publish diagnostic and notify log events directly to Amazon CloudWatch Logs. Analyze the log data with CloudWatch Logs, then use CloudWatch to create alarms and view metrics.
With CloudWatch Logs, you can do the following:
-
Store logs in highly durable storage space with a retention period that you define.
-
Search and filter log data.
-
Share log data between accounts.
-
Export logs to Amazon S3.
-
Stream data to Amazon OpenSearch Service.
-
Process log data in real time with Amazon Kinesis Data Streams. For more information, see Working with Amazon CloudWatch Logs in the Amazon Managed Service for Apache Flink for SQL Applications Developer Guide.
Amazon RDS publishes each RDS for Db2 database log as a separate database stream in the log
group. For example, if you publish the diagnostic logs and notify logs, diagnostic data
is stored in a diagnostic log stream in the
/aws/rds/instance/
log group, and notify log data is stored in the
my_instance
/diagnostic/aws/rds/instance/
log
group.my_instance
/notify
Note
Publishing RDS for Db2 logs to CloudWatch Logs isn't enabled by default. Publishing self-tuning memory manager (STMM) and optimizer statistics logs isn't supported. Publishing RDS for Db2 logs to CloudWatch Logs is supported in all Regions, except for Asia Pacific (Hong Kong).
To publish RDS for Db2 logs to CloudWatch Logs from the AWS Management Console
Open the Amazon RDS console at https://console.aws.amazon.com/rds/
. -
In the navigation pane, choose Databases, and then choose the DB instance that you want to modify.
-
Choose Modify.
-
In the Log exports section, choose the logs that you want to start publishing to CloudWatch Logs.
You can choose diag.log, notify.log, or both.
-
Choose Continue, and then choose Modify DB Instance on the summary page.
To publish RDS for Db2 logs, you can use the modify-db-instance
command with the following
parameters:
-
--db-instance-identifier
-
--cloudwatch-logs-export-configuration
Note
A change to the --cloudwatch-logs-export-configuration
option
is always applied to the DB instance immediately. Therefore, the
--apply-immediately
and --no-apply-immediately
options have no effect.
You can also publish RDS for Db2 logs using the following commands:
Example
The following example creates an RDS for Db2 DB instance with CloudWatch Logs
publishing enabled. The --enable-cloudwatch-logs-exports
value
is a JSON array of strings that can include diag.log
,
notify.log
, or both.
For Linux, macOS, or Unix:
aws rds create-db-instance \ --db-instance-identifier
mydbinstance
\ --enable-cloudwatch-logs-exports '["diag.log","notify.log"]' \ --db-instance-classdb.m4.large
\ --enginedb2-se
For Windows:
aws rds create-db-instance ^ --db-instance-identifier
mydbinstance
^ --enable-cloudwatch-logs-exports "[\"diag.log\",\"notify.log\"]" ^ --db-instance-classdb.m4.large
^ --enginedb2-se
Note
When using the Windows command prompt, you must escape double quotes (") in JSON code by prefixing them with a backslash (\).
Example
The following example modifies an existing RDS for Db2 DB instance to publish
log files to CloudWatch Logs. The --cloudwatch-logs-export-configuration
value is a JSON object. The key for this object is
EnableLogTypes
, and its value is an array of strings that
can include diag.log
, notify.log
, or both.
For Linux, macOS, or Unix:
aws rds modify-db-instance \ --db-instance-identifier
mydbinstance
\ --cloudwatch-logs-export-configuration '{"EnableLogTypes":["diag.log","notify.log"]}'
For Windows:
aws rds modify-db-instance ^ --db-instance-identifier
mydbinstance
^ --cloudwatch-logs-export-configuration "{\"EnableLogTypes\":[\"diag.log\",\"notify.log\"]}"
Note
When using the Windows command prompt, you must escape double quotes (") in JSON code by prefixing them with a backslash (\).
Example
The following example modifies an existing RDS for Db2 DB instance to disable
publishing diagnostic log files to CloudWatch Logs. The
--cloudwatch-logs-export-configuration
value is a JSON
object. The key for this object is DisableLogTypes
, and its
value is an array of strings that can include diag.log
,
notify.log
, or both.
For Linux, macOS, or Unix:
aws rds modify-db-instance \ --db-instance-identifier
mydbinstance
\ --cloudwatch-logs-export-configuration '{"DisableLogTypes":["diag.log"]}'
For Windows:
aws rds modify-db-instance ^ --db-instance-identifier
mydbinstance
^ --cloudwatch-logs-export-configuration "{\"DisableLogTypes\":[\"diag.log\"]}"
Note
When using the Windows command prompt, you must escape double quotes (") in JSON code by prefixing them with a backslash (\).