This topic describes how to enable the SQL audit and analysis feature in the PolarDB-X 1.0 console.

Prerequisites

  • Log Service is activated.
  • A PolarDB-X 1.0 instance is purchased.
  • A database is created.

Procedure

Important Before you can use a RAM user to enable the SQL audit and analysis feature, you must grant the required permissions to the RAM user. For more information, see Authorize a RAM user to use the access log feature.
  1. Log on to the PolarDB-X 1.0 console.
  2. In the upper-left corner of the page, select the region where the instance resides.
  3. On the Instance List page, click the name of the instance.
  4. In the left-side navigation pane, choose Diagnostics and Optimization > SQL Audit and Analysis.
  5. Authorize PolarDB-X 1.0 as prompted to assume the AliyunDRDSDefaultRole role to access Log Service.
    This operation is required only when you enable the SQL audit and analysis feature for the first time. You must complete the authorization by using your Alibaba Cloud account.
    Warning To ensure that PolarDB-X 1.0 SQL audit logs can be sent to Log Service, do not revoke the permissions from the AliyunDRDSDefaultRole role or delete the RAliyunDRDSDefaultRole role.
  6. Enable the SQL audit and analysis feature.
    1. Select the database, and then turn on the switch next to the database or turn on the SQL Audit Log Status of Current Database switch.
      Enable the SQL audit and analysis feature
    2. Optional:Import historical data.

      By default, only the logs that are generated after the SQL audit and analysis feature is enabled are sent to Log Service. If you want to analyze logs that are generated before the SQL audit and analysis feature is enabled, you can import historical data. To do so, you can turn on the Import Historical Data or Not switch in the Log Storage Period dialog box. Then, set the Trace Start Time and Trace End Time parameters. You can import up to seven days of historical data.

      You can view the log import progress in the Task Progress dialog box in the upper-right corner of the current page.

      Import historical data
    3. Click Enable.

Result

After PolarDB-X 1.0 SQL audit logs are collected and sent to Log Service, you can query, analyze, download, ship, and transform the collected logs. You can also configure alerts for the logs. For more information, see Common operations on logs of Alibaba Cloud services.