All Products
Search
Document Center

ApsaraDB for SelectDB:Use the query audit feature

Last Updated:Mar 28, 2025

The query audit feature allows you to monitor, record, and analyze SQL statements executed in databases. Database administrators (DBAs) can use the query audit feature to track user operations on databases, such as retrieving data, updating data, deleting data, and collecting and analyze slow SQL queries. This way, DBAs can track and analyze the use of databases in a comprehensive manner to monitor the security and stability of databases. This topic describes how to use the query audit feature of ApsaraDB for SelectDB.

Prerequisites

  • A SelectDB instance is created. For more information, see Create an instance.

  • The version of the instance is 3.0.7 or later.

Procedure

  1. Log on to the SelectDB console.

  2. In the top navigation bar, select the region in which the instance that you want to manage resides.

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

  4. Click Data Development and Management in the upper-right corner.

    Note

    If you use the tools of Data Development and Management for the first time, a message appears and prompts you to add the public IP address of your machine to the IP address whitelist named webui_whitelist of the instance. Read the message and click OK.

  5. Select Query Audit from the drop-down list.

    Note
    • If you use Query Audit for the first time and have not logged on to the WebUI system, the WebUI logon page appears.

      • You can use the admin account to log on to the WebUI system.

      • If you do not know or forget the password of the admin account, you can reset the password. For more information, see Reset the password of an account.

    • By default, the query audit feature is enabled.

    • By default, the Query Audit page displays all audit logs in the previous 8 hours.

  6. On the Query Audit page, perform the following operations based on your business requirements:

    • Enable query audit: In the upper-right corner of the page, click the Query Audit Configuration icon. In the Query Audit Configuration dialog box, turn on Query Audit and click Confirm to enable the query audit feature.

      Important

      After you enable the query audit feature, the queries that you initiate are logged in the audit log table. These logs occupy a certain amount of storage space.

    • Disable query audit: In the upper-right corner of the page, click the Query Audit Configuration icon. In the Query Audit Configuration dialog box, turn off Query Audit and click Confirm to disable the query audit feature.

      Important

      If you disable the query audit feature, the system immediately stops writing audit logs to the audit log table. The written audit logs remain unchanged.

    • View audit logs: In the upper part of the page, configure the Logs and Status parameters, and select the time range to query. Click the Filter icon, enable the filter conditions that you want to use, and then click Confirm. The system displays the data that meets the specified filter conditions.

    • Download audit logs: In the upper-right corner of the page, click the Download icon to download the queried audit logs.

    • View profile information: Find the query that you want to view and click its ID in the Query ID column to go to the query details page. Click Query Profile in the upper-left corner of the page. The execution plan appears. You can perform the following operations:

    • Important

      Before you use this feature, you must take note of the following items:

      • The logon account must be admin.

      • If your instance runs SelectDB Core 4.0 or later, you can use the feature to view a profile online and download the profile. If your instance runs SelectDB Core 3.0, you can use the feature only to download the profile.

      • View profile information online and analyze the execution of the SQL statement.

      • Download the profile.

        Note

        By default, the query profile feature is enabled for all queries initiated on the SQL Editor page. This may slightly affect the performance of a single query.

Related API operations

ResetAccountPassword

DescribeSecurityIPList

ModifySecurityIPList

References

Create an instance

Reset the password of an account

Configure an IP address whitelist