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.

Prerequisites

  • The instance is a general-purpose instance with local disks or a dedicated instance with local disks.
    Note You can check the instance type of the instance in the Category column of the tables in the Instance types topic.
  • The instance that was purchased from June 6, 2021 to November 25, 2021 requires the audit log feature. In the Audit Log Filter Setting panel, slow is selected for the instance. You can enable the audit log feature in the ApsaraDB for MongoDB console (for more information, see Enable the audit log feature) or by calling the ModifyAuditPolicy operation.
    Note The instance is free of charged if only slow is selected in the Audit Log Filter Setting panel.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.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 CloudDBA > Slow Query Logs.
    By default, slow query logs generated in the last 15 minutes are displayed in the trend chart. You can also specify a time range of no more than three hours and click Search to view the slow query logs. The maximum time range that you can specify is three days. Slow query log trends
  6. View slow query logs by using one of the following methods:
    • View slow query logs on the Slow Log Statistics tab.
      Note
      • If the request content of the database is hidden, you can move the pointer over the corresponding Request Content column and view the complete content.
      • You can click Export Slow Log on the Slow Log Statistics tab to save the log data to your computer.
    • View slow query logs on the Slow Log Details tab.
      On the Slow Log Details page, select the name of the database whose slow query logs you want to view.
      Note If the request content of the database is hidden, you can move the pointer over the corresponding Request Content column and view the complete content.