You can view the slow query logs of a database in the console and optimize the database accordingly by analyzing slow query logs.
A replica set instance with three or more nodes or a sharded cluster instance is created.
- 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.
- You can only view slow query logs that are generated after the audit logs feature is enabled.
- For more information about how to enable the audit logs feature, see Enable the new audit log feature for an ApsaraDB for MongoDB instance.
- For more information about how to set the operation types, see Modify the settings of the audit log feature.
- Log on to the ApsaraDB for MongoDB console.
- In the upper-left corner of the page, select the resource group and the region of the target instance.
- In the left-side navigation pane, click Replica Set Instances, or Sharded Cluster Instances based on the instance type.
- Find the target instance and click its ID.
- In the left-side navigation pane, choose .
- 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.