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 must meet the following requirements:
    • If the instance is a replica set one, the instance runs MongoDB 5.0 or earlier.
    • If the instance is a sharded cluster one, the instance runs MongoDB 5.0 or earlier.
  • 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.

Procedure

  1. 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..
    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.
    • 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).
    Note 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.