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 of the General-purpose Local-disk and Dedicated Local-disk type.
Note You can view the instance type in the Instance type column.

Precautions

The retention period for slow query logs is 72 hours.

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 based on the instance type.
  3. In the upper-left corner of the page, select the resource group and region to which the instance belongs.
  4. Click the ID of an instance, or click More icon in the Actions column corresponding to the instance and select Manage.
  5. In the left-side navigation pane of the instance details page, choose Logs > Slow Query Logs.
  6. View slow query logs based on the instance type.
    • Replica set instance
      Specify the database name and time range to view slow query logs.
    • Sharded cluster instance
      Specify the database name, shard node ID, and time range to view slow query logs.