Help Center> Relational Database Service> API Reference> Historical APIs> API v3> Querying Database Slow Logs (RDS for MySQL)
Updated on 2024-04-01 GMT+08:00

Querying Database Slow Logs (RDS for MySQL)

Function

This API is used to query the latest 2,000 database slow query logs.

This API will be unavailable on March 31, 2025. You are advised to switch workloads to the new API (Querying Database Slow Logs (MySQL)) before then.

  • Before calling an API, you need to understand the API in Authentication.

Constraints

Only the MySQL DB instances are supported.

URI

  • URI format

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

  • Parameter description
    Table 1 Parameter description

    Name

    Mandatory

    Description

    project_id

    Yes

    Project ID of a tenant in a region.

    For details about how to obtain the project ID, see Obtaining a Project ID.

    instance_id

    Yes

    Specifies the ID of the instance to be queried.

    start_date

    Yes

    Specifies the start time 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.

    end_date

    Yes

    Specifies the end time 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. You can only query slow logs generated within a month.

    offset

    No

    Specifies the page offset, for example, 1, 2, 3, or 4. If this parameter is not specified, the default value is 1, indicating that data on the first page is queried.

    The latest 2,000 slow query logs can be queried. The value of offset multiplied by the value of limit must be no more than 2,000. For example, if the value of offset is set to 200, and the value of limit cannot be greater than 10.

    limit

    No

    Specifies the number of records on each page. Its value range is from 1 to 100. The parameter value is 10 by default if it is not specified.

    type

    No

    Specifies the statement type. If it is left blank, all statement types are queried. Valid value:

    • INSERT
    • UPDATE
    • SELECT
    • DELETE
    • CREATE

Request

  • Request parameters

    None

  • URI example

    GET https://{endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/cee5265e1e5845649e354841234567dfin01/slowlog?offset=1&limit=10&start_date=2018-08-06T10:41:14+0800&end_date=2018-08-07T10:41:14+0800&type=INSERT

Response

  • Normal response
    Table 2 Parameter description

    Name

    Type

    Description

    slow_log_list

    Array of objects

    Indicates detailed information.

    For details, see Table 3.

    total_record

    Integer

    Indicates the total number of records.

    Table 3 slow_log_list field data structure description

    Name

    Type

    Description

    count

    String

    Indicates the number of executions.

    time

    String

    Indicates the execution time.

    lock_time

    String

    Indicates the lock wait time.

    rows_sent

    String

    Indicates the number of sent rows.

    rows_examined

    String

    Indicates the number of scanned rows.

    database

    String

    Indicates the database which the slow log belongs to.

    users

    String

    Indicates the account.

    query_sample

    String

    Indicates the execution syntax. By default, slow query logs are anonymized. To display them in plaintext, contact customer service to add a whitelist.

    type

    String

    Indicates the statement type.

    start_time

    String

    Indicates the start time in the UTC format.

    client_ip

    String

    Indicates the IP address.

  • 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.