Enabling SQL Audit
After you enable the SQL audit function, all SQL operations will be recorded in log files. You can download audit logs to view log details.
By default, SQL audit is disabled because enabling this function may affect database performance. This section describes how to enable, modify, or disable SQL audit.
Supported Database Versions
- RDS for MySQL 5.6 instances using cloud disks: 5.6.43 and later versions
- RDS for MySQL 5.7 instances using cloud disks: 5.7.23 and later versions
- RDS for MySQL 8.0
Constraints
- Both primary DB instances and read replicas support SQL audit logging.
- After SQL auditing is enabled, RDS records SQL operations in audit logs. The generated audit log files are temporarily stored in the instance and then uploaded to OBS and stored in the backup space. If there is not enough free backup space available for generated audit logs, the additional space required is billed.
- Audit logs are cleared every hour. After you change the retention period of audit logs, expired audit logs will be deleted 1 hour later.
- After SQL auditing is enabled, a large number of audit logs may be generated during peak hours. As a result, there are many audit log files temporarily stored in the instance, and the storage may be full.
- Log in to the management console.
- Click
in the upper left corner of the page and choose Databases > Relational Database Service. - On the Instances page, click the target instance name.
- In the navigation pane on the left, choose Logs. On the displayed page, click the SQL Audit Logs tab.
- On the displayed tab page, click Set SQL Audit. In the displayed dialog box, specify parameters and click OK.
Enabling or setting SQL audit
- To enable SQL audit, toggle on the switch (from
to
). - Audit logs can be retained from 1 to 732 days and are retained for 7 days by default.
Disabling SQL audit
To disable SQL audit, toggle
(enabled) to
(disabled). - To enable SQL audit, toggle on the switch (from
- Log in to the management console.
- Click
in the upper left corner of the page and choose Databases > Relational Database Service. - On the Instances page, click the target instance name.
- In the navigation pane on the left, choose Logs. On the displayed page, click the SQL Audit Logs tab.
- Click
next to the Report Audit Logs to LTS field. - Select an LTS log group and log stream and click OK.
- After this function is enabled, audit logs record all requests sent to your DB instance and are stored in LTS.
- This function does not take effect immediately. There is a delay of about 10 minutes.
- After this function is enabled, all audit policies are reported by default.
- Keep the following points in mind before you enable audit logging or audit log reporting to LTS:
- Enabling audit logging or audit log reporting to LTS generates audit logs and the sensitive information in the audit logs is not anonymized.
- If you enable audit logging first and then enable audit log reporting to LTS, LTS reuses the audit policy set for your instance and you will also be billed for reporting audit logs to LTS. Only after you disable audit logging, billing for audit logging will be terminated.
- If you enable audit logging first and then enable audit log reporting to LTS, you are not advised to disable audit logging before audit log reporting to LTS is running properly.
- Audit logs may be lost while being uploaded to LTS in certain situations. If audit logging is enabled, you can download all audit logs from OBS.
- There is a low probability that some logs are lost when the service traffic is heavy, audit logs are generated too fast, or the LTS service fails.
- Each audit log record uploaded to LTS cannot exceed 512 KB. Larger records will be truncated.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.