tencent cloud


Slow Log Management

Last updated: 2022-04-08 10:15:41

    You can view and analyze the slow logs generated during database operations in the TencentDB for MongoDB console for targeted database performance optimization.


    • Slow logs are often used as the basis for optimizing business operations in MongoDB. For more information, see Database Profiler.
    • The system provides two query methods as described below:
      • Query statistics: slow logs for the specified time period are queried, and the query results are aggregated and analyzed by command (operation) type.
      • Query details: a specific operation command is specified to query slow logs, and the query results are displayed in a list displaying the execution durations and log details.

    Version Description

    Currently, TencentDB for MongoDB 4.2, 4.0, 3.6, and 3.2 support slow log management.


    • The system logs operations with an execution time of more than 100 ms.
    • The slow logs are retained for 7 days. The time span for a single query cannot exceed 1 day.
    • Only the first 10,000 slow logs can be queried. If the query is slow, you can narrow down the query time period.



    Querying slow log

    1. Log in to the TencentDB for MongoDB console.
    2. In the MongoDB drop-down list on the left sidebar, select Replica Set Instance or Sharded Instance. The directions for the two types of instances are similar.
    3. Above the instance list on the right, select the region.
    4. In the instance list, find the target instance.
    5. Click the target instance ID to enter the Instance Details page.
    6. Select the Database Management > Slow Log Query tab.
    7. On the Slow Log Query tab, select a query method to query slow logs.
    • Query statistics: select a query time period, set the time consumed threshold, and click Query.
    • Query details:
      1. Select the specific executed command to be queried in Executed Command.
      2. Select a query time period, set the time consumed threshold, and click Query.
    1. View and analyze the slow logs.
    • A statistics query result contains four fields:
      • Query Method: statistics query.
      • Sample Command: output statements aggregated in the command type dimension. You mainly need to refer to the command when troubleshooting problems.
      • Average Execution Time (ms): average execution time (in ms) of operations aggregated in the command type dimension.
      • Total: total occurrences of operations aggregated in the command type dimension.
    • A details query result contains three fields:
      • Query Method: details query.
      • Time Consumed: execution time of the business command (in ms).
      • Log Details: details of the business command.

    Slow log management

    Viewing slow log request statement

    1. On the Slow Query Management page, you can view the slow log request statements.
    2. In the search box in the top-right corner, enter the information to be queried for search.
      Query StatementQuery statement.
      Op TypeOperation type.
      Node LocationNode of the executed operation.
      NamespaceNamespace of the database table.
      Executed TimeTime consumed.
      DetailsDetails of the executed statement.

    Batch killing

    1. On the Slow Query Management page, select the slow log request statements to be cleared.
    2. Click Batch Kill above the list.
    3. In the Note pop-up window, read the prompt carefully.
    4. Click OK.

    Downloading slow log file

    1. On the Slow Log Download List page, you can view current slow log files.
    2. Find the file to be downloaded and click Download in the Operation column.
    API Description
    DescribeSlowLogs Gets slow log information
    DescribeSlowLogPatterns Gets slow log statistics
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support