This topic describes how to view slow query logs of ApsaraDB for MongoDB instances. You can identify, analyze, diagnose, and track slow query logs to create indexes. This improves the utilization of the instance resources.
A replica set instance or sharded cluster instance that runs MongoDB 4.2 or later is created.
- 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
. Note By default, slow query logs generated in the past 15 minutes are displayed in the trend chart. You can specify the time range and click Search to view slow query logs. The maximum time range is one day.
- View details of slow query logs based on the following methods:
- Click the Slow Log Details tab under the trend chart.
- On the Slow Log Details tab, select the database that you want to query.
Note If the request content of the database is hidden, you can move the pointer over the corresponding content in the Request Content column and view the complete content.
- In the trend chart, click the time point of a specific slow query log and view its details on the Slow Log Statistics tab.
- On the Slow Log Statistics tab, click Sample in the Actions column.
In the Slow Log Sample dialog box, you can view details of the slow query log.Note If the request content of the database is hidden, you can move the pointer over the corresponding content in the Request Content column and view the complete content.
Export slow query logs
You can click Export Slow Log on the Slow Log Statistics tab to save the slow query log information to your computer.