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 more than three nodes or a sharded cluster instance is used.

Precautions

The retention period for slow logs is 72 hours.

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.