SQL audit logs real-time DML and DDL operations in your AnalyticDB for MySQL databases, giving you a complete record of database activity for security investigations and compliance reviews.
费用
目前SQL审计功能正在公测,公测期间免费使用。公测期结束后,AnalyticDB for MySQL会免费保留最近1个月的审计日志,1个月以上收取存储空间费用。
Unsupported operations
The following operations are not recorded in SQL audit logs:
INSERT INTO VALUESREPLACE INTO VALUESUPSERT INTO VALUES
Enable or disable SQL audit
Prerequisites
Before you begin, ensure that you have:
An AnalyticDB for MySQL cluster
Access to the AnalyticDB for MySQL console
Enable SQL audit
Log on to the AnalyticDB for MySQL console. In the upper-left corner, select a region. In the left-side navigation pane, click Clusters, find the cluster you want to manage, and click the cluster ID.
Go to the SQL Audit page:
Enterprise Edition, Basic Edition, or Data Lakehouse Edition: In the left-side navigation pane, choose Cluster Management > SQL Audit.
Data Warehouse Edition: In the left-side navigation pane, click Data Security, then click the SQL Audit tab.
Click Configure SQL Audit.
In the Configure SQL Audit dialog box, select Yes and click OK.

Disable SQL audit
Disabling SQL audit permanently clears all existing audit logs. Export your logs before disabling. After you re-enable SQL audit, only logs generated from the time of re-enablement are available.
To disable SQL audit, repeat steps 1–3 from the enable procedure, then select No in the Configure SQL Audit dialog box and click OK.
Query and export SQL audit logs
On the SQL Audit tab, filter audit logs by Operation Type or Execution Status to find specific database activity.
Audit logs are available for the last 30 days only. Each query must cover a time range within 24 hours.
To save logs to your local machine, click Export Current Page.
FAQ
Why does the INSERT OVERWRITE statement produce two audit log entries, one with an IP address that is not the client IP address?
INSERT OVERWRITE runs asynchronously in AnalyticDB for MySQL. The access node distributes query jobs across storage nodes and then returns the result to the client. Because of this, the audit logs capture two IP addresses: the client IP address that submitted the request, and the IP address of the AnalyticDB for MySQL access node.
API reference
| Edition | Operation |
|---|---|
| Enterprise Edition, Basic Edition, and Data Lakehouse Edition | ModifyAuditLogConfig |
| Enterprise Edition, Basic Edition, and Data Lakehouse Edition | DescribeAuditLogRecords |
| Data Warehouse Edition | DescribeAuditLogConfig |
| Data Warehouse Edition | ModifyAuditLogConfig |
| Data Warehouse Edition | DescribeAuditLogRecords |