All Products
Search
Document Center

ApsaraDB RDS:Use the SQL Explorer and Audit feature

Last Updated:Aug 18, 2026

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

Important

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:

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 LOGIN operation 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) or loose_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_version parameter to MYSQL_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 DescribeSQLLogRecords and DescribeSQLLogFiles API 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 PROCESSLIST returns. 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.
  1. 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.

  2. In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.

  3. Click Enable DAS Enterprise Edition V3.image

  4. Select the sub-features to enable and click Submit.

Modify the storage duration

Warning

Reducing the storage duration immediately deletes audit logs retained longer than the new duration. Export and save your logs before reducing the storage duration.

  1. Go to the Instances page. Select the region, find the instance, and click its ID.

  2. In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.

  3. Click Service Settings.

  4. In the Service Settings panel, modify the storage duration and click Submit.

Disable SQL Explorer and Audit

Warning

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.

  1. Go to the Instances page. Select the region, find the instance, and click its ID.

  2. In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.

  3. 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.
  4. In the dialog box, configure Exported Fields and Export Time Range, then click OK.

  5. Download the exported log file and save it locally.

  6. 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

Warning

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

FAQ

What does the `logout!` statement in Full Request Statistics indicate?

logout! marks a disconnection event. The execution duration shown is the idle time between the last interaction and the disconnection. Status code 1158 means network disconnection, which can happen because:

  • The client connection timed out

  • The server disconnected

  • The connection exceeded the interactive_timeout or wait_timeout value

Why does a percent sign (%) appear in the Access Source column on the Source Statistics tab?

A % in the Access Source column appears when a stored procedure is involved. This happens because the stored procedure is defined with a DEFINER that includes % as the host — for example, ` CREATE DEFINER=test_user@% PROCEDURE das() `.

To reproduce this behavior:

  1. In the ApsaraDB RDS console, create a database and a standard account, and grant permissions on the database to that account. For details, see Create accounts and databases.

  2. Connect to the instance using the test_user account via the CLI. For details, see Use a database client or the CLI to connect to an ApsaraDB RDS for MySQL instance.

  3. Switch to the testdb database and create a stored procedure:

    -- Switch to testdb
    USE testdb;
    
    -- Create a stored procedure
    DELIMITER $$
    DROP PROCEDURE IF EXISTS `das` $$
    CREATE DEFINER=`test_user`@`%` PROCEDURE `das`()
    BEGIN
    SELECT * FROM information_schema.processlist WHERE Id = CONNECTION_ID();
    END $$
    DELIMITER;
  4. Connect to the instance using a privileged account. For details, see Use a database client or the CLI to connect to an ApsaraDB RDS for MySQL instance.

  5. Call the stored procedure:

    -- Switch to testdb
    USE testdb;
    
    -- Call the stored procedure
    CALL das();

    Expected output:

    +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+
    | ID     | USER      | HOST   | DB     | COMMAND | TIME | STATE     | INFO                                                                    |
    +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+
    | 487818 | test_user | %:2065 | testdb | Query   |    0 | executing | SELECT * FROM information_schema.processlist WHERE Id = CONNECTION_ID() |
    +--------+-----------+--------+--------+---------+------+-----------+-------------------------------------------------------------------------+

After executing a query that returns results, the Logs section shows zero scanned rows. Why?

The fast query cache feature is enabled. When the same query hits the cache, MySQL returns the cached result directly without scanning InnoDB — so the scanned row count is zero. For details, see Fast query cache.

What are the differences between SQL Explorer logs and binary logs?

Both log types capture incremental changes to your RDS instance, but they differ in coverage and use cases:

SQL Explorer logs

Binary logs

Coverage

All DQL, DML, and DDL operations

Add, delete, and modify operations only

Completeness

Small number of records may be lost under heavy load

Accurate within the backup retention period

Availability

Real-time

Not generated in real time; periodically transferred to Object Storage Service (OSS), retained for 7 days

Includes source IP and account

Yes

No

Best for

Compliance auditing, troubleshooting, full activity analysis

Data recovery using accurate incremental data

Binary log files currently being written cannot be transferred to OSS. As a result, some files may fail to upload when using the Upload Binlogs feature. For details, see How do I remotely obtain and parse the binary log file of an ApsaraDB RDS for MySQL instance?

The SQL Explorer entry point has disappeared from the console. Why?

SQL Explorer and Audit is an updated version of SQL Explorer. The entry point is now labeled SQL Explorer and Audit.

Can I enable the original SQL Explorer feature?

No. Only the latest version of SQL Explorer and Audit can be enabled on RDS instances.

Are SQL audit records deleted from the system after I export them?

No. Exporting audit records does not delete them from the system.

Does SQL Explorer and Audit support configuring alerts at the database account level, for example, excluding a specific account from alert notifications?

No. Alert and audit settings for SQL Explorer and Audit apply at the instance level and cannot be differentiated for individual database accounts. For example, you cannot configure "user A does not receive alerts" or "audit only the operations of user B". To manage alert notifications per user, filter them in your application layer or by using Cloud Monitor notification policies.

How do I use audit logs to trace the source of a data deletion?

If table data is accidentally or maliciously deleted, you can use SQL Explorer and Audit to identify the account and IP address that performed the deletion:

  1. Log on to the ApsaraDB RDS console. Find the instance and click its ID.

  2. In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.

  3. On the Audit tab, in the Logs section, set the time range to cover the period when the deletion occurred, and optionally filter by database name.

  4. Enter DELETE in the SQL keyword search box and click the search icon.

  5. In the results, find the DELETE operation record and click it to view details, including the account name and client IP address.

Note

The IP address (HostAddress) recorded in audit logs may be the RDS proxy IP address rather than the actual client IP address. To confirm the actual source of the operation, cross-reference your VPC network configuration or check the client-side connection logs.

How do I combine error log fields to filter audit records?

Fields from error logs, such as the database name and client IP address, can be used as filter conditions in SQL Explorer and Audit to locate abnormal connections. Procedure:

  1. Log on to the ApsaraDB RDS console and go to the instance details page. In the left-side navigation pane, choose Autonomy Services > SQL Explorer and Audit.

  2. On the Audit tab, click Enable Advanced Query to expand the advanced filter conditions.

  3. In the Database field, enter the database name, for example, battery.

  4. In the Client IP field, enter the host from the error log, for example, 172.25.244.207.

  5. Set the Time Range to cover the period when the abnormal connection occurred.

  6. Click Query to run the combined filter query.

Note

The Client IP filter condition is displayed only after you click Enable Advanced Query. By default, only the time range, keyword, user, database, and operation type filter conditions are shown.

How do I query the logon history of an instance?

You can filter Search (audit) results by operation type. On the SQL Explorer and Audit page, open the Search tab and set the Operation type filter to LOGIN to query the logon history of the instance. The result list includes the User (logon account) and Client IP columns, which help you identify who logged on and from where.

What do I do if I cannot find the SQL statement that changed the status of a specific row?

SQL Explorer and Audit records operations at the SQL statement level and does not provide before-and-after value comparison at the field level. To view the value of a specific field, such as status, before and after a change, use the data tracking feature of Data Management (DMS) to locate the source of the change.