You can call this operation to query slow logs of an ApsaraDB for Redis instance within a specified period.

For more information about how to perform the corresponding operation in the console, see Query slow logs of an instance.

Debugging

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

Request parameters

Parameter Type Required Example Description
Action String No DescribeSlowLogRecords

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

InstanceId String Yes r-bp1xxxxxxxxxxxxx

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 ISO 8601 standard 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. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The end time must be later than the start time.

RegionId String No cn-hangzhou

The ID of the region.

NodeId String No r-bp1xxxxxxxxxxxxx-db-0

The ID of the child node in the cluster. If you want to query slow logs of a specified node, you must specify this parameter.

DBName String No redisdemo

The name of the database.

PageSize Integer No 30

The maximum number of logs to return on each page.

PageNumber Integer No 1

The number of the page to return.

SlowLogRecordType String No proxy

The type of the slow logs. Valid values:

  • proxy: slow logs of proxy nodes.
  • db: slow logs of the database nodes.
Note Default value: proxy.
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 order of the returned results. Valid values:

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

The order of the returned results. Valid values:

  • execution_time: specifies that the returned data is sorted by the beginning time of queries.
  • latency: specifies that the returned data is sorted by the execution time of queries.
Note Default value: execution_time

Response parameters

Parameter Type Example Description
Engine String Redis

The engine type of the instance.

InstanceId String r-bp1xxxxxxxxxxxxx

The ID of the instance.

Items Array

The slow logs returned.

LogRecords
Account String 0

The ID of the account.

AccountName String demo

The name of the member account.

Command String KEYS *

The slow query statement that was run.

DBName String -1

The name of the database.

DataBaseName String -1

The name of the database.

ElapsedTime Long 248

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

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

The beginning of the time when the slow query statement started to run. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format.

IPAddress String xxx.xxx.xxx.100

The IP address of the client.

NodeId String r-bp1xxxxxxxxxxxxx-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 number of logs 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 logs returned.

RequestId String 686BB8A6-BBA5-47E5-8A75-D2ADE433917A

The ID of the request.

Examples

Sample requests

https://r-kvstore.aliyuncs.com/
?Action=DescribeSlowLogRecords
&InstanceId=r-bp1xxxxxxxxxxxxx
&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>xxx.xxx.xxx.100</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-bp1xxxxxxxxxxxxx-db-1</InstanceId>
      <RequestId>686BB8A6-BBA5-47E5-8A75-D2ADE433917A</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": "xxx.xxx.xxx.100",
                "Account": "0",
                "AccountName": "0",
                "DataBaseName": "-1",
                "DBName": "-1"
            }
        ]
    },
    "PageNumber": 1,
    "TotalRecordCount": 1,
    "PageSize": 30,
    "InstanceId": "r-bp1xxxxxxxxxxxxx-db-1",
    "RequestId": "686BB8A6-BBA5-47E5-8A75-D2ADE433917A",
    "StartTime": "2019-03-10T13:11Z",
    "Engine": "Redis",
    "PageRecordCount": 1
}

Error codes

HttpCode Error code Error message Description
400 InvalidStartTime.Malformed The Specified parameter StartTime is not valid. The error message returned because the format of the beginning time is invalid. The time must be in GMT. Example: 2011-06-11T16:00Z.
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.