Use SQL audit to search SQL execution history, investigate slow queries or security incidents, and export log records for compliance review.
Prerequisites
Before you begin, ensure that you have:
Enabled the SQL Explorer and Stress Testing (New) feature
(RAM users only) One of the following permissions:
The AliyunDRDSReadOnlyWithSQLLogArchiveAccess policy, granted by your Alibaba Cloud account. See Grant permissions to a RAM user.
A custom policy that grants access to the search and export features in the SQL Explorer and Audit module. See What do I do if I do not have permissions to access DAS as a RAM user.
Query and export SQL logs
Click the Audit tab and select the nodes to audit.
NoteTo set the storage duration of SQL logs, click Service Settings.
Set your query conditions using Set Query Conditions or Enable Advanced Query, then click Query. The following parameters are available:
Parameter Description Input format Time range Filters by SQL statement execution duration Select a start and end time Keyword Filters by keywords in the SQL statement Enter one or more keywords separated by spaces. Select OR to match any keyword, or AND to require all keywords User Filters by database account name Enter one or more account names separated by spaces Database Filters by database name Enter one or more database names separated by spaces Operation type Filters by SQL operation type Select one or more: SELECT, INSERT, UPDATE, DELETE, LOGIN, LOGOUT, MERGE, ALTER, CREATE, DROP, SET, DESC, REPLACE, CALL, BEGIN, DESCRIBE, ROLLBACK, FLUSH, USE, SHOW, START, COMMIT, RENAME, TRUNCATE Client IP address Filters by the IP address of the client that ran the SQL statement Enter one or more IP addresses separated by spaces Execution status Filters by whether execution succeeded Select Completed, Failed, or both Execution duration Filters by how long the SQL statement took to run Enter a range in milliseconds, for example, 100-5000Updated/returned rows Filters by the number of rows updated or returned Enter a range, for example, 0-1000Physical SQL statements Filters by the number of SQL statements actually executed Enter a value Tracking ID Filters by the request ID between the compute node and data node Copy the tracking ID from a log record in your query results Transaction ID Filters by the transaction ID generated during execution Copy the transaction ID from a log record in your query results SQL ID Filters by the SQL template ID Enter one or more SQL IDs separated by spaces. Find SQL IDs in SQL Explorer 
(Optional) To export log records, click Export, select the Export Fields to include, and set an Export Time Range if you need records beyond the current query window.
NoteTo check the status of recent export tasks, click View Export List.