ApsaraDB for MongoDB allows you to identify, analyze, diagnose, and track slow query logs so that you can create indexes to make better use of instance resources.
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.
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 . .
On the page that appears, view the information in the Slow Log Trend and Nodes sections and on the Slow Log Statistics and Slow Log Details tabs.Note
For replica set instances, the Nodes tab is not displayed.
Slow Log Trend: displays the trend chart of slow query logs within the last 15 minutes by default. The longest time range to query is the last 3 hours.
Nodes: displays the number of slow queries that are run on each node.
Slow Log Statistics: displays the statistics of slow query logs. The metrics include Total Executions, Avg Execution Duration (ms), Max Execution Duration (ms), Avg Returned Rows, and Max Returned Rows.
Slow Log Details: displays the details of slow query logs. The metrics include Execution Finish Time, Database, Request Content, Client, and Execution Duration (ms).
On the Slow Log Statistics or Slow Log Details tab, you can click Export Slow Log to save the statistics or details to your computer.
By default, only queries that take more than 100 milliseconds are considered as slow queries. You can modify the time threshold by using the operationProfiling.slowOpThresholdMs parameter. For more information, see Configure database parameters for an ApsaraDB for MongoDB instance.