You can view the slow query logs of a database in the console and optimize the database accordingly by analyzing slow query logs.

Prerequisites

A replica set instance with three or more nodes or a sharded cluster instance is created.

Precautions

  • The retention period for slow query logs is 72 hours.
  • If the instance is purchased after June 6, 2021 and you want to view its slow query logs, you must enable the audit logs feature and select the admin and slow operation types that you want to audit.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. In the left-side navigation pane, click Replica Set Instances, or Sharded Cluster Instances based on the instance type.
  4. Find the target instance and click its ID.
  5. In the left-side navigation pane, choose Logs > Slow Query Logs.
  6. View slow query logs based on instance types:
    • Replica set instances: You can select the database name and time range to query the corresponding slow query logs.
    • Sharded cluster instances: You can select the database name, shard node ID and time range to view the corresponding slow query logs.