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.
Precautions
- The retention period for slow query logs is seven days.
- Slow query logs cannot be deleted.
Procedure
- Log on to the ApsaraDB for MongoDB console.
- In the left-side navigation pane, click Replica Set Instances or Sharded Cluster Instances based on the instance type.
- In the upper-left corner of the page, select the resource group and region to which the instance belongs.
- Click the ID of an instance, or click
in the Actions column corresponding to the instance and select Manage.
- In the left-side navigation pane of the instance details page, choose .
- View slow query logs based on the instance type.
- Replica set instanceSpecify the database name and time range to view slow query logs.
- Sharded cluster instanceSpecify the database name, shard node ID, and time range to view slow query logs.
- Replica set instance
References
For more information about how to view detailed slow query logs or export slow query logs, see Slow query logs.