SQL Explorer and Audit captures every SQL statement executed on your ApsaraDB RDS for MySQL instance — including the account, source IP address, and execution details — and stores them as audit logs. Use this data to:
-
Retain a complete audit trail of all Data Query Language (DQL), Data Manipulation Language (DML), and Data Definition Language (DDL) operations for security compliance
-
Investigate performance issues, abnormal sessions, and SQL health status
-
Recover data by replaying recorded SQL statements after data loss or corruption
SQL Explorer and Audit captures data directly from database kernels using a small amount of CPU resources. Enabling and using the feature has minimal impact on instance performance.
Prerequisites
Before you begin, ensure that you have:
-
Database Autonomy Service (DAS) Enterprise Edition enabled on your Alibaba Cloud account
-
An RDS instance in a region supported by DAS Enterprise Edition
If a RAM user needs to use the SQL statement search feature, attach the AliyunRDSReadOnlyWithSQLLogArchiveAccess policy to that RAM user. For details, see Use RAM to manage ApsaraDB RDS permissions or grant permissions using a custom policy that covers the search and export features.
In the ApsaraDB RDS console, only the SQL Explorer and Audit feature provided by the latest version of DAS Enterprise Edition supported in the current region can be enabled.
Supported regions
China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Hong Kong), Singapore, Japan (Tokyo), Malaysia (Kuala Lumpur), Indonesia (Jakarta), US (Silicon Valley), UK (London), US (Virginia), Germany (Frankfurt)
Capabilities
|
Capability |
Description |
|
Search (audit) |
Query and export SQL statement execution records — including database, status, and execution time |
|
SQL Explorer |
Diagnose SQL health, troubleshoot performance issues, and analyze business traffic |
|
Security audit |
Identify risks: high-risk SQL statements, SQL injection attacks, and new access sources |
|
Traffic playback and stress testing |
Replay real traffic to verify whether your instance needs to scale out |
|
SQL analysis |
Analyze SQL statements over a time range to surface abnormal queries and locate performance bottlenecks |
This feature is suitable for:
-
Sectors requiring high data security, such as finance, security, stocks, public service, and insurance
-
Troubleshooting, SQL performance analysis, and abnormal session identification
-
Data loss or corruption recovery using SQL statements recorded by the feature
Billing
Billing depends on when and how you enabled the feature.
If you enabled the original SQL Explorer feature before it was upgraded to SQL Explorer and Audit, the fee is included in your ApsaraDB RDS bill. Pricing is based on instance region and billed per GB-hour:
|
Rate |
Regions |
|
USD 0.0012/GB-hour |
China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu) |
|
USD 0.0015/GB-hour |
China (Hong Kong), US (Silicon Valley), US (Virginia) |
|
USD 0.0018/GB-hour |
Singapore, Japan (Tokyo), Germany (Frankfurt), UAE (Dubai), Malaysia (Kuala Lumpur), Indonesia (Jakarta), UK (London) |
To upgrade from SQL Explorer to SQL Explorer and Audit: log on to the ApsaraDB RDS console, go to the SQL Explorer tab, and click One click upgrade in the dialog box. After the upgrade, billing moves to your DAS bill.
If SQL Explorer and Audit is enabled after the upgrade, the fee is included in your DAS bill. Supported regions and rates vary by DAS Enterprise Edition version. For details, see DAS editions and supported features and Billing.
Limits
Online query limits
-
Time range: Each query covers a window of up to 24 hours. To query records spanning more than 24 hours, use Simple Log Service (SLS) to access SQL Explorer logs. For details, see Collect RDS SQL audit logs.
-
Query method: Combine multiple filter conditions. Fuzzy match is not supported. Each keyword must contain at least four characters.
SQL Explorer and Audit limits
-
Storage location: Audit logs are stored separately by Database Autonomy Service (DAS) and do not consume the local disk space of your RDS instance. Enabling SQL Explorer and Audit does not increase the disk usage of your instance.
-
Logon records: ApsaraDB RDS for MySQL does not record logon events by default. Logon events are recorded only after you enable SQL Explorer and Audit, after which you can trace logon records by using the
LOGINoperation type. Logons that occurred before you enabled the feature are not retained and cannot be retrieved afterwards. -
Maximum SQL statement length: Up to 8,192 bytes. The limit is controlled by
loose_rds_audit_max_sql_size(MySQL 5.6 and 5.7) orloose_rds_audit_log_event_buffer_size(MySQL 8.0) — the smallest value among the three parameters applies. Because a prefix is added during data collection, the effective limit is slightly below 8,192 bytes or your configured value. -
Querying by transaction ID: Set the
loose_rds_audit_log_versionparameter toMYSQL_V3, and make sure the minor engine version meets the requirements: MySQL 8.0 requires version 20210930 or later; MySQL 5.7 requires version 20210630 or later. For details, see Parameters supported by ApsaraDB RDS instances that run MySQL 8.0 and Upgrade the minor engine version. -
SQL Explorer Trial Edition: The
DescribeSQLLogRecordsandDescribeSQLLogFilesAPI operations are not available. For details, see DescribeSQLLogRecords and DescribeSQLLogFiles. -
Lock wait time: Recorded in SQL Explorer logs but not in slow query logs.
-
Prepare method: SQL Explorer records two statements for each prepared statement — one with a question mark (
?) placeholder and one with the actual value.
Other considerations
-
Database proxy with transaction-level connection pool: When the transaction-level connection pool is enabled, connections may be reused. The IP address and port in SQL Explorer logs may differ from what
SHOW PROCESSLISTreturns. For details, see What are database proxies? -
PolarDB-X 1.0 attached instances: SQL statements executed on an RDS instance attached to PolarDB-X 1.0 generate multiple SQL Explorer log entries due to horizontal sharding.
Enable SQL Explorer and Audit
Enabling the audit log collection feature for your RDS instance in the CloudLens for RDS application of Simple Log Service automatically enables SQL Explorer and Audit. For details, see CloudLens for RDS.
If SQL Explorer and Audit is disabled and you need to view SQL execution records, check binary logs. Binary logs only contain add, delete, and modify operations within the backup retention period — source IP addresses and accounts are not available. For details, see Manage binary log files.
-
Go to the Instances page. In the top navigation bar, select the region where the RDS instance resides. Find the instance and click its ID.
-
In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.
-
Click Enable DAS Enterprise Edition V3.

-
Select the sub-features to enable and click Submit.
Modify the storage duration
Reducing the storage duration immediately deletes audit logs retained longer than the new duration. Export and save your logs before reducing the storage duration.
-
Go to the Instances page. Select the region, find the instance, and click its ID.
-
In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.
-
Click Service Settings.
-
In the Service Settings panel, modify the storage duration and click Submit.
Disable SQL Explorer and Audit
Disabling SQL Explorer and Audit permanently deletes all audit logs. Export your logs before disabling the feature. If you re-enable the feature later, logs are recorded from the re-enable point — previous logs are not restored.
-
Go to the Instances page. Select the region, find the instance, and click its ID.
-
In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.
-
In the Logs section of the Search tab, click Export.
Each export covers up to 10 million records within a 7-day window. Use the Export Time Range parameter to export logs across a wider time range.
-
In the dialog box, configure Exported Fields and Export Time Range, then click OK.
-
Download the exported log file and save it locally.
-
Click Service Settings and disable the feature. If DAS Enterprise V3 is activated, clear all features in the SQL Explorer and Audit module and click Submit.
Storage space occupied by SQL Explorer and Audit data is released one hour after the feature is disabled.
Migrate data between DAS Enterprise Edition versions
Data migration cannot be stopped or rolled back. Read the migration instructions carefully before proceeding.
If your RDS instance supports DAS Enterprise Edition V3, migrate data from V1 or V2 to V3 to reduce costs. For migration steps, see How do I migrate data between versions of DAS Enterprise Edition?
Each version uses a different storage architecture:
-
V1: Original storage architecture
-
V2: Hybrid storage of hot and cold data — higher performance at lower cost than V1
-
V3: Hybrid storage of hot and cold data with per-feature billing — more flexible than V2