Queries slow logs of an ApsaraDB for Redis instance within a specified period.

You can also query slow logs in the ApsaraDB for Redis console. For more information, see Query slow logs of an instance.

This operation can be called up to 100 times per minute.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer automatically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSlowLogRecords

The operation that you want to perform. Set the value to DescribeSlowLogRecords.

InstanceId String Yes r-bp1zxszhcgatnx****

The ID of the instance.

StartTime String Yes 2019-03-10T14:11Z

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

EndTime String Yes 2019-03-22T14:11Z

The end of the time range to query. The end time must be later than the beginning time. The time range cannot exceed one day. We recommend that you set the time range to one hour. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

RegionId String No cn-hangzhou

The ID of the region where the instance is deployed.

NodeId String No r-bp1zxszhcgatnx****-db-0

The ID of the node on the instance. You can set this parameter to query the slow logs of a specified node.

Note This parameter is available only for read/write splitting instances or cluster instances of ApsaraDB for Redis.
DBName String No 0

The name of the database.

PageSize Integer No 30

The number of entries to return on each page. Valid values: 30, 50, and 100. Default value: 30.

PageNumber Integer No 1

The number of the page to return. The value must be an integer that is greater than 0 and does not exceed the maximum value of the Integer data type. Default value: 1.

SlowLogRecordType String No proxy

The type of slow log. Valid values:

  • proxy: slow logs of the proxy nodes.
  • db: slow logs of data nodes.
Note Default value: db.
QueryKeyword String No keyword1

The keyword based on which slow logs are queried. You can set this parameter to a value of the string type.

OrderType String No ASC

The sorting method of the results to return. Valid values:

  • ASC: ascending order.
  • DESC: descending order.
Note Default value: DESC.
OrderBy String No execution_time

The dimension by which the results to return are sorted. Valid values:

  • execution_time: specifies that the results to return are sorted by the start time of queries.
  • latency: specifies that the results to return are sorted by the execution time of queries.
Note Default value: execution_time.

Response parameters

Parameter Type Example Description
Engine String Redis

The database engine type of the instance.

InstanceId String r-bp10n********

The ID of the instance.

Items Array of LogRecords

The slow logs returned.

LogRecords
Account String 0

The ID of the account.

AccountName String demo

The name of the account.

Command String KEYS *

The slow query statement.

DBName String -1

The name of the database.

DataBaseName String -1

Database name, which serves the same purpose as the DBName parameter. We recommend that you use the value of the DBName parameter.

ElapsedTime Long 248

The amount of time to run the slow query statement. Unit: milliseconds.

ExecuteTime String 2019-03-20T09:18:41Z

The time when the slow query statement was run. The time is displayed in the yyyy-MM-ddTHH:mm:ssZ format.

IPAddress String 172.16.88.***

The IP address of the client.

NodeId String r-bp1zxszhcgatnx****-db-0

The ID of the node.

PageNumber Integer 1

The page number of the returned page.

PageRecordCount Integer 1

The number of logs returned on the current page.

PageSize Integer 30

The maximum number of log entries returned per page.

StartTime String 2019-03-10T13:11Z

The beginning of the time range where slow logs were queried.

TotalRecordCount Integer 1

The total number of returned log entries.

RequestId String 686BB8A6-BBA5-47E5-8A75-D2ADE433****

The ID of the request.

Examples

Sample requests

https://r-kvstore.aliyuncs.com/?Action=DescribeSlowLogRecords
&InstanceId=r-bp1zxszhcgatnx****
&StartTime=2019-03-10T14:11Z
&EndTime=2019-03-22T14:11Z
&<Common request parameters>

Sample success responses

XML format

<DescribeSlowLogRecordsResponse>
      <Items>
            <LogRecords>
                  <Command>KEYS *</Command>
                  <ExecuteTime>2019-03-20T09:18:41Z</ExecuteTime>
                  <ElapsedTime>248</ElapsedTime>
                  <IPAddress>172.16.88. ***</IPAddress>
                  <Account>0</Account>
                  <AccountName>0</AccountName>
                  <DataBaseName>-1</DataBaseName>
                  <DBName>-1</DBName>
            </LogRecords>
      </Items>
      <PageNumber>1</PageNumber>
      <TotalRecordCount>1</TotalRecordCount>
      <PageSize>30</PageSize>
      <InstanceId>r-bp1zxszhcgatnx****-db-1</InstanceId>
      <RequestId>686BB8A6-BBA5-47E5-8A75-D2ADE433****</RequestId>
      <StartTime>2019-03-10T13:11Z</StartTime>
      <Engine>Redis</Engine>
      <PageRecordCount>1</PageRecordCount>
</DescribeSlowLogRecordsResponse>

JSON format

{
    "Items": {
        "LogRecords": [
            {
                "Command": "KEYS *",
                "ExecuteTime": "2019-03-20T09:18:41Z",
                "ElapsedTime": 248,
                "IPAddress": "172.16.88. ***",
                "Account": "0",
                "AccountName": "0",
                "DataBaseName": "-1",
                "DBName": "-1"
            }
        ]
    },
    "PageNumber": 1,
    "TotalRecordCount": 1,
    "PageSize": 30,
    "InstanceId": "r-bp1zxszhcgatnx****-db-1",
    "RequestId": "686BB8A6-BBA5-47E5-8A75-D2ADE433****",
    "StartTime": "2019-03-10T13:11Z",
    "Engine": "Redis",
    "PageRecordCount": 1
}

Error codes

HttpCode Error code Error message Description
400 InvalidEndTime.Malformed The Specified parameter EndTime is not valid. The error message returned because the format of the end time is invalid. The time must be in GMT. Example: 2011-06-11T16:00Z.

For a list of error codes, visit the API Error Center.