Last updated: 2021-12-01 10:57:57

1. API Description

Domain name for API request:

This API is used to query the slow query log list.

A maximum of 20 requests can be initiated per second for this API.

We recommend you to use API Explorer
Try it
API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: DescribeDBSlowLogs.
Version Yes String Common parameter. The value used for this API: 2017-03-12.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
InstanceId Yes String Instance ID in the format of tdsql-ow728lmc.
Offset Yes Integer Data entry number starting from which to return results
Limit Yes Integer Number of results to be returned
StartTime Yes Timestamp Query start time in the format of 2016-07-23 14:55:20
EndTime No Timestamp Query end time in the format of 2016-08-22 14:55:20
Db No String Specific name of database to be queried
OrderBy No String Sort by metric. Valid values: query_time_sum, query_count
OrderByType No String Sorting order. Valid values: desc, asc
Slave No Integer Whether to query slow queries of the secondary. 0: primary, 1: secondary

3. Output Parameters

Parameter Name Type Description
Data Array of SlowLogData Slow query log data
LockTimeSum Float Sum of all statement lock durations
QueryCount Integer Total number of statement queries
Total Integer Total number of results
QueryTimeSum Float Sum of all statement query durations
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Querying the slow query log list

Input Example
&StartTime=2017-08-06 00:00:00
&EndTime=2017-08-07 23:59:59
&<Common request parameters>

Output Example

  "Response": {
    "RequestId": "1e74e824-6d2b-495d-b347-5250cdf8e964",
    "Data": [
        "CheckSum": "14090621765287179955",
        "Db": "",
        "FingerPrint": "replace into sysdb.statustable set ts = from_unixtime(?),ip=?,port=?",
        "LockTimeAvg": "0.00",
        "LockTimeMax": "0.00",
        "LockTimeMin": "0.00",
        "LockTimeSum": "0.00",
        "QueryCount": "1",
        "QueryTimeAvg": "1.13",
        "QueryTimeMax": "1.13",
        "QueryTimeMin": "1.13",
        "QueryTimeSum": "1.13",
        "RowsExaminedSum": "0.00",
        "RowsSentSum": "0.00",
        "TsMax": "2016-08-06 11:32:10",
        "TsMin": "2016-08-06 11:32:10",
        "User": "agent"
    "LockTimeSum": 0,
    "QueryCount": 1,
    "QueryTimeSum": 1.13,
    "Total": 1

5. Developer Resources


TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
InternalError.CamAuthFailed CAM authentication request failed.
InternalError.DbOperationFailed Failed to query the database.
InternalError.GetInstanceInfoFailed Failed to get the backend instance information.
InternalError.GetSlowLogFailed Failed to get the error log.
InternalError.LogDBFailed Failed to get slow logs.
InvalidParameter.GenericParameterError An error occurred while verifying parameter validity.
InvalidParameter.IllegalTime Incorrect time parameter.
ResourceUnavailable.InstanceAlreadyDeleted The database instance has been deleted.
ResourceUnavailable.InstanceStatusAbnormal Incorrect database instance status. Operations are not allowed.
UnauthorizedOperation.PermissionDenied You have no permission to manipulate this API or resource.