All Products
Search
Document Center

ApsaraDB for MongoDB:View slow query logs

Last Updated:Feb 28, 2024

You can view the slow query logs of a database in the ApsaraDB for MongoDB console and analyze the logs to optimize the database.

Prerequisites

  • The instance is a replica set instance or a sharded cluster instance.

    Important

    You can find standalone instances in the replica set instance list, but you cannot view slow query logs of standalone instances.

  • If the instance was purchased between June 6, 2021 and November 25, 2021, the audit log feature is enabled and slow is selected in the Audit Log Filter Setting panel. For more information about how to enable the audit log feature, see Enable the audit log feature.

    Note

    If only slow is selected in the Audit Log Filter Setting panel, the audit log feature is offered free of charge.

Usage notes

  • The retention period of slow query logs is seven days.

  • Slow query logs cannot be deleted.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.

  2. In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances.

  3. In the upper-left corner of the page that appears, select the resource group and region to which the desired instance belongs.

  4. Click the ID of the instance that you want to manage or click Manage in the Actions column.

  5. In the left-side navigation pane of the instance details page, choose Logs > Slow Query Logs.

  6. Perform operations to view slow query logs based on the instance type.

    • Replica set instances

      Specify the database name and time range to view slow query logs.

    • Sharded cluster instances

      Specify the database name, shard node ID, and time range to view slow query logs.

    Note

    Click Export to download the slow query logs to your on-premises computer.

References

For more information about how to view detailed slow query logs or export slow query logs, see Slow query logs.