All Products
Search
Document Center

ApsaraDB for SelectDB:Use the query audit feature

Last Updated:Mar 28, 2026

Query audit records every SQL statement executed against your SelectDB databases, giving database administrators (DBAs) visibility into who ran what, when, and how long it took. Use query audit to:

  • Track data retrieval, modification, and deletion operations by user

  • Identify and investigate slow queries

  • Monitor database security and stability

  • Download audit logs for offline analysis

  • Inspect execution plans for individual queries

Prerequisites

Before you begin, ensure that you have:

Navigate to query audit

  1. Log on to the SelectDB console.

  2. In the top navigation bar, select the region where your instance resides.

  3. In the left-side navigation pane, click Instances. On the Instances page, click the instance ID to go to the Instance Details page.

  4. In the left-side navigation pane, choose Data Development and Management (Studio) > Query Audit.

    The first time you open any Data Development and Management (Studio) tool, a prompt asks you to add your machine's public IP address to the webui_whitelist IP address whitelist. Click OK to proceed.
    The first time you open Query Audit, the WebUI logon page appears if you have not already logged on. Use the admin account to log on.

The Query Audit page opens. By default, it shows all audit logs from the previous 8 hours.

Enable or disable query audit

Query audit is enabled by default. To change the setting:

  1. In the upper-right corner of the Query Audit page, click the Query Audit Configuration icon.

  2. In the Query Audit Configuration dialog box, turn Query Audit on or off.

  3. Click Confirm.

Important

When query audit is enabled, the queries that you initiate are logged in the audit log table, which consumes storage space.

Important

When you disable query audit, the system immediately stops writing new audit logs. Existing audit logs are not deleted.

View and filter audit logs

The Query Audit page lists all audit log entries.

To filter the list:

  1. In the upper part of the page, configure the available filter parameters:

    FilterUse case
    LogsFilter by log type
    StatusFind failed, slow, or canceled queries
    Time rangeLimit results to a specific period. By default, the page shows logs from the previous 8 hours.
  2. Click the Filter icon to open the filter panel. Enable the conditions you want to apply, then click Confirm.

The page refreshes to show only the entries that match your filter conditions.

Download audit logs

In the upper-right corner of the Query Audit page, click the Download icon to download the currently filtered audit logs.

View a query profile

A query profile shows the execution plan for a specific query, which helps you diagnose performance issues.

Requirements:

  • The account must be admin.

  • SelectDB Core 4.0 or later: view the profile online and download it.

  • SelectDB Core 3.0: download the profile only — online viewing is not available.

Query profile collection is enabled by default for all queries run on the SQL Editor page, which may slightly affect the performance of individual queries.

To view a query profile:

  1. On the Query Audit page, find the query you want to investigate and click its Query ID.

  2. On the query details page, click Query Profile in the upper-left corner. The execution plan appears. Depending on your instance version, you can view the profile inline or download it.

Troubleshooting

Query Audit page is inaccessible or prompts for logon

The first time you access Data Development and Management (Studio) features, the console prompts you to add your machine's IP address to the webui_whitelist whitelist. If you skipped this step, add your IP address manually. For instructions, see Configure an IP address whitelist.

If the WebUI logon page appears, log on with the admin account. If you have forgotten the password, see Reset the password of an account.

Query Profile button is unavailable or profile cannot be viewed online

The Query Profile feature requires the admin account. If the button is unavailable, confirm that you are logged on as admin.

If you can download the profile but cannot view it online, your instance runs SelectDB Core 3.0. Online profile viewing requires SelectDB Core 4.0 or later.

Related topics

Related API operations