All Products
Search
Document Center

PolarDB:DescribeSlowLogRecords

Last Updated:Mar 01, 2024

Queries the details of the slow query logs of a cluster.

Operation description

Note This operation is applicable only to PolarDB for MySQL clusters.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
polardb:DescribeSlowLogRecordsREAD
  • dbcluster
    acs:polardb:{#regionId}:{#accountId}:dbcluster/{#dbclusterId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
RegionIdstringYes

The region ID of the cluster.

Note You can call the DescribeRegions operation to query all regions that are available for your account, such as the region ID.
cn-hangzhou
DBClusterIdstringYes

The ID of cluster.

Note You can call the DescribeDBClusters operation to query information about all clusters that are deployed in a specified region, such as the cluster ID.
pc-************
StartTimestringYes

The beginning of the time range to query. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Note
  • You can specify a time range of up to 30 days.

  • This parameter must be set to a time value in UTC (UTC+0 time zone). If your service resides in another time zone, convert the time value. For example, if the local time in the time zone where your service resides is 12:00 (UTC +8) and you want to query slow query logs at 08:00 (UTC +8) to 12:00, set this parameter to a time value that ranges from 00:00, set this parameter to 04:00.

2022-11-15T16:00Z
EndTimestringYes

The end of the time range to query. The end time must be later than the start time. The interval between the start time and end time must be within 24 hours. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Note This parameter must be set to a time value in UTC (UTC+0 time zone). If your service resides in another time zone, convert the time value. For example, if the local time in the time zone where your service resides is 12:00 (UTC +8) and you want to query slow query logs at 08:00 (UTC +8) to 12:00, set this parameter to a time value that ranges from 00:00, set this parameter to 04:00.
2022-11-16T04:00Z
DBNamestringNo

The name of the database.

testdb
PageSizeintegerNo

The number of entries to return on each page. Valid values:

  • 30
  • 50
  • 100

Default value: 30.

30
PageNumberintegerNo

The number of the page to return. The value must be an integer that is larger than 0.

Default value: 1.

1
SQLHASHstringNo

The unique ID of the SQL statement. The ID is used to obtain the slow query logs of the SQL statement.

U2FsdGVk****

Response parameters

ParameterTypeDescriptionExample
object
TotalRecordCountinteger

The total number of SQL statements.

1
PageRecordCountinteger

The number of entries returned per page.

1
RequestIdstring

The ID of the request.

A7E6A8FD-C50B-46B2-BA85-D8B8D3******
PageNumberinteger

The number of the returned page.

1
DBClusterIdstring

The ID of cluster.

pc-*****************
Itemsobject []

Details about slow query logs.

ExecutionStartTimestring

The time when the SQL statement was executed. The time is in the yyyy-MM-ddTHH:mmZ format. The time is displayed in UTC.

2021-04-07T03:47Z
HostAddressstring

The IP address of the client that is used to connect to the database.

testdb[testdb] @ [100.**.**.242]
QueryTimeslong

The amount of time that was consumed to execute the SQL statement. Unit: seconds.

20
SQLTextstring

The SQL statement that is executed in the query.

/* Query from *** by user 111 */ SELECT sleep(20)
ReturnRowCountslong

The number of rows returned by the SQL statement.

0
ParseRowCountslong

The number of rows parsed by the SQL statement.

0
DBNamestring

The name of the database.

testdb
LockTimeslong

The period of time during which the SQL statement was locked. Unit: seconds.

0
DBNodeIdstring

The ID of the node.

pi-*****************
QueryTimeMSlong

The time range for the query. Unit: milliseconds.

100
Enginestring

The type of the database engine.

polardb_mysql

Examples

Sample success responses

JSONformat

{
  "TotalRecordCount": 1,
  "PageRecordCount": 1,
  "RequestId": "A7E6A8FD-C50B-46B2-BA85-D8B8D3******",
  "PageNumber": 1,
  "DBClusterId": "pc-*****************",
  "Items": {
    "SQLSlowRecord": [
      {
        "ExecutionStartTime": "2021-04-07T03:47Z",
        "HostAddress": "testdb[testdb] @  [100.**.**.242]",
        "QueryTimes": 20,
        "SQLText": "/* Query from *** by user 111 */ SELECT sleep(20)",
        "ReturnRowCounts": 0,
        "ParseRowCounts": 0,
        "DBName": "testdb",
        "LockTimes": 0,
        "DBNodeId": "pi-*****************",
        "QueryTimeMS": 100
      }
    ]
  },
  "Engine": "polardb_mysql"
}

Error codes

HTTP status codeError codeError messageDescription
400InvalidStartTime.MalformedThe specified parameter StartTime is not valid.The specified StartTime parameter is invalid.
404InvalidDBClusterId.NotFoundThe DBInstanceId provided does not exist in our records.The specified DBClusterId parameter does not exist in the current record.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
2023-06-12The Error code has changedsee changesets
Change itemChange content
Error CodesThe Error code has changed.
    Added Error Codes: 400
    Added Error Codes: 404