All Products
Search
Document Center

PolarDB:Subscribe to PolarDB for MySQL cluster logs

Last Updated:Jun 21, 2026

To meet enterprise requirements for custom log management, PolarDB integrates with Simple Log Service (SLS) to provide a data subscription feature. This feature delivers all logs from your PolarDB for MySQL clusters to a centralized project in SLS for unified management. This topic explains how to subscribe to and view logs for PolarDB for MySQL clusters.

Usage notes

  • The PolarDB cluster must be a PolarDB for MySQL cluster.

  • PolarDB supports collecting the following four types of logs:

    • Audit logs

    • Slow Query Logs

    • Error logs

    • Performance logs

  • To collect audit logs, you must enable SQL Explorer for the target cluster. SQL Explorer is billed based on the storage size of audit logs. For more information, see SQL Explorer billing.

    Note

    SQL Explorer is not required if you only need to collect slow query logs or performance logs.

Enable PolarDB log collection

  1. Log on to the Simple Log Service console.

  2. In the Log application area, on the Audit & security tab, click Log Audit Service.

  3. Configure authorization for log collection and synchronization.

  4. On the Access to cloud products > Global configurations page, configure the following settings.

    1. From the Region of the central project drop-down list, select the destination region for centralized log storage.

      This central project receives all data that you configure for collection in the subsequent steps.

      Note

      For more information about central projects, see Project.

    2. In the list of cloud products, enable the switch for each PolarDB log type you want to collect. You can choose from Audit logs, Slow Query Logs, Error logs, and Performance logs.

      To the left of each log type is a collection switch, which is disabled by default. After you enable the switch, you can configure the collection policy. The default storage mode is Centralized with a retention period of 180 days. For audit logs, slow query logs, and error logs, you can also set an additional retention period (default 30 days).

    3. Click Collection policy next to the target log type. In the Collection policy configuration dialog box, add your cluster's region to the policy. If you do not add a region, the system creates a Logstore for each region. For more information, see Logstore and Collection policy.

      After you complete the configuration, click OK.

      Note

      You can also configure other collection policies. The following collection policies are available for PolarDB for MySQL clusters:

      • account.id: The Alibaba Cloud account ID of the PolarDB for MySQL cluster.

      • region: The region where the PolarDB for MySQL cluster is deployed, for example, cn-hangzhou.

      • cluster.id: The ID of the PolarDB for MySQL cluster.

      • cluster.name: The name of the PolarDB for MySQL cluster.

      • cluster.db_type: The database type compatible with the PolarDB for MySQL cluster. Currently, only MySQL is supported.

      • cluster.db_version: The database version. Valid values: 8.0, 5.7, and 5.6.

      • tag.*: The name of a custom tag. Replace the asterisk (*) with your custom tag name. For more information about PolarDB for MySQL cluster tags, see Add tags.

    4. In the upper-right corner of the outermost Global configurations area, click Save.

      Note

      After you save the configuration, it may take about 2 minutes for the initial synchronization to complete. If an error occurs, adjust the settings based on the on-screen prompts.

  5. In the dialog box that appears, click Go to access status to view the access status.

    You can also choose Access to cloud products > Status dashboard from the left-side navigation pane to check the status.

View collected PolarDB logs

  1. Log on to the Simple Log Service console.

  2. On the Global configurations tab, click the central project you created. The project name is in the format slsaudit-center-<Alibaba Cloud account ID>-<region ID>.

  3. On the Audit query tab on the right, click PolarDB to expand the Logstore and view the log details.

    Click the audit log icon in the left-side icon bar to expand the navigation menu. The service is listed under the Centralized category.

Disable PolarDB log collection

  1. Stop collecting PolarDB logs. For more information, see More operations.

    Note

    It takes about 2 minutes for the change to take effect.

  2. Open Cloud Shell.

  3. Run the following command to delete the project.

    aliyunlog log delete_project --project_name=<project_name> --region-endpoint=<region_ID>.log.aliyuncs.com
    Important

    This operation deletes all data in the project. Proceed with caution.

Log fields

See Fields of PolarDB for MySQL logs.