Help Center/ Relational Database Service/ API Reference/ API v3.1 (Recommended)/ Querying Database Slow Logs (RDS for MySQL)
Updated on 2025-08-20 GMT+08:00

Querying Database Slow Logs (RDS for MySQL)

Function

This API is used to query the latest slow logs of a DB instance. A maximum of 2,000 log records can be queried.

Constraints

This API is supported only for MySQL.

URI

  • URI format

    GET /v3.1/{project_id}/instances/{instance_id}/slowlog?start_date={start_date}&end_date={end_date}

  • Parameter description
    Table 1 Parameters

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Definition

    Project ID of a tenant in a region.

    To obtain the value, see Obtaining a Project ID.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    instance_id

    Yes

    Definition

    ID of the instance to be queried.

    Constraints

    N/A

    Range

    N/A

    Default Value

    N/A

    start_date

    Yes

    Definition

    Start time.

    Constraints

    N/A

    Range

    The value is in the "yyyy-mm-ddThh:mm:ssZ" format.

    T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800.

    Default Value

    N/A

    end_date

    Yes

    Definition

    End time.

    Constraints

    You can only query slow logs generated within a month.

    Range

    The value is in the "yyyy-mm-ddThh:mm:ssZ" format.

    T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800.

    Default Value

    N/A

    offset

    No

    Definition

    Index offset. The query starts from the next piece of data indexed by this parameter.

    Constraints

    A maximum of 2,000 log records can be queried.

    Range

    The value must be a non-negative number. The value of offset plus the value of limit must be no more than 2000. For example, if the value of offset is set to 1900, and the value of limit cannot be greater than 100.

    Default Value

    0: The query starts from the first data record.

    limit

    No

    Definition

    Number of records (query results) displayed on each page.

    Constraints

    N/A

    Range

    1–100

    Default Value

    10

    type

    No

    Definition

    SQL statement type.

    Constraints

    N/A

    Range

    If it is left blank, all statement types are queried. Valid values:

    • INSERT
    • UPDATE
    • SELECT
    • DELETE
    • CREATE

    Default Value

    N/A

Request

  • Request parameters

    None

Response

  • Normal response
    Table 2 Parameters

    Parameter

    Type

    Description

    slow_log_list

    Array of objects

    Definition

    Detailed information.

    For details, see Table 3.

    total_record

    Integer

    Definition

    Total number of records.

    Range

    N/A

    Table 3 slow_log_list field data structure description

    Parameter

    Type

    Description

    count

    String

    Definition

    Number of executions.

    Range

    N/A

    time

    String

    Definition

    Execution time.

    Range

    N/A

    lock_time

    String

    Definition

    Lock wait time.

    Range

    N/A

    rows_sent

    String

    Definition

    Number of sent rows.

    Range

    N/A

    rows_examined

    String

    Definition

    Number of scanned rows.

    Range

    N/A

    database

    String

    Definition

    Database which slow logs belong to.

    Range

    N/A

    users

    String

    Definition

    Account.

    Range

    N/A

    query_sample

    String

    Definition

    Execution syntax. By default, slow query logs are anonymized. To display them in plaintext, contact customer service.

    Range

    N/A

    type

    String

    Definition

    Statement type.

    Range

    N/A

    start_time

    String

    Definition

    Start time in the UTC format.

    Range

    N/A

    client_ip

    String

    Definition

    IP address.

    Range

    N/A

  • Example normal response
    {
        "total_record": 1,
        "slow_log_list": [
            {
                "count": "1",
                "time": "1.04899 s",
                "lock_time": "0.00003 s",
                "rows_sent": "0",
                "rows_examined": "0",
                "database": "mysql",
                "users": "root",
                "query_sample": "INSERT INTO time_zone_name (Name, Time_zone_id) VALUES (N, @time_zone_id);",
                "type": "INSERT",
                "start_time": "2018-08-06T10:41:14",
                "client_ip": "192.*.*.1"
            }
        ]
    }
  • Abnormal response

    For details, see Abnormal Request Results.

Status Code

Error Code

For details, see Error Codes.