This topic describes how to use Database Autonomy Service (DAS) to enable, use, and disable slow query log analysis for ApsaraDB for MongoDB instances. To manage multiple database instances, you can view global slow query log trends. This feature allows you to find the most frequently executed slow SQL statement and the instance where the number of executed slow SQL statements is the largest.

Enable slow query log analysis

  1. Log on to the DAS console.
  2. Connect an ApsaraDB for MongoDB instance to DAS and make sure that the instance is in the Accessed state.
  3. In the left-side navigation pane, click Instance Monitoring. On the page that appears, find the database instance and check whether the instance is in the Accessed state. If the instance is in the Accessed state, move on to the next step.
  4. Click the ID of the instance. In the instance details page, choose Request Analysis > Slow Logs in the left-side navigation pane.
  5. Click Enable Slow Log Analysis.
    Note By default, the slow query log analysis feature is disabled. You can view the slow query log trends after the feature is enabled for about 30 minutes.

Slow query log trends

In the Slow Log Trend section, you can view the number of slow SQL statements for the instance by hour.

  • You can click a dot in the chart to view the slow query log details that are collected at a specific period of time.
    Note The slow query log analysis feature shows the slow query statistics and provides an easy method for you to find the most frequently executed slow SQL statement and the most time-consuming slow SQL statement. You can also find the slow query log where the SQL requests scan the largest average number of rows.
  • You can click Sample in the Actions column to view the request details, including the slow query log information, the username, and the client IP address.

Global slow query log trend

In the left-side navigation pane of the DAS console, choose Request Analysis > Slow Logs to view the slow query log trends of all connected databases.