All Products
Search
Document Center

ApsaraDB for OceanBase:SQL audit

Last Updated:Apr 29, 2024

This topic describes how to perform request analysis by querying the SQL statements on the SQL Audit page.

Background information

SQL audit allows you to query SQL statements of a cluster based on information such as the user who executed an SQL statement, IP address, and operation type, and export the query results.

SQL audit

  1. Go to the Clusters page of the ApsaraDB for OceanBase console.

  2. Click the name of the target cluster to go to the cluster management page.

  3. In the left-side navigation bar, click Diagnose.

  4. On the diagnostics page, click the SQL Audit tab.

    image

  5. If it is the first time that you use the tab, take the following steps to enable the SQL audit feature.

    1. Select a tenant.

      image

    2. Click Start SQL Audit.

      image

    3. In the dialog box that appears, specify the corresponding parameters.

      image

    4. Click Enable.

  6. On the SQL Audit tab, perform the following operations to query the SQL statements that may have issues.

    1. Filter the information based on the specified conditions.

      Filter item

      Description

      Database

      Select one or more databases in the corresponding tenant.

      Node

      Select one or more nodes.

      Keyword

      Select one or more keywords that may exist in the problematic SQL statements. The relationship between the keywords can be AND or OR.

      Time Range

      You can select the last 5 minutes, 30 minutes, 1 hour, 6 hours, or a custom time range. The time range cannot exceed 6 hours.

      Username

      Enter one or more tenant names.

      Operation Type

      Select one or more operation types from the drop-down list.

      Client IP Address

      Enter the IP address of the client.

      Execution Duration (ms)

      Enter the execution duration for the target SQL statement.

      Scan Records

      Enter the range of scan records to view.

    2. View the query result. You can view the query result in the following columns: SQL Statement, Database, User, Client IP Address, Operation Type, Request Time, Execution Duration (ms), Scanned Rows, and Updated Rows.

    3. Download the query result: Click Export to download the query result.2

      Note

      At present, you can download at most 100 audit records. If the number of query records exceeds 100, only the first 100 records on the page are downloaded.