All Products
Search
Document Center

:DescribeSlowLogRecords

Last Updated:Dec 09, 2024

Queries the slow query logs of a Tair (Redis OSS-compatible) instance that are generated within a specified period of time.

Operation description

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

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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
kvstore:DescribeSlowLogRecordsget
*DBInstance
acs:kvstore:{#regionId}:{#accountId}:dbinstance/{#dbInstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The ID of the instance.

r-bp1zxszhcgatnx****
NodeIdstringNo

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

Note This parameter is available only if the instance uses the read/write splitting or cluster architecture.
r-bp1zxszhcgatnx****-db-0
StartTimestringYes

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.

2019-03-10T14:11Z
EndTimestringYes

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

2019-03-22T14:11Z
DBNamestringNo

The name of the database.

0
PageSizeintegerNo

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

30
PageNumberintegerNo

The number of the page to return. The value must be an integer that is greater than 0. Default value: 1.

1
SlowLogRecordTypestringNo

The type of the slow logs. Default value: db. Valid values:

  • proxy: slow logs of proxy nodes
  • db: slow logs of data nodes
proxy
QueryKeywordstringNo

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

keyword1
OrderTypestringNo

The sorting order of the results to return. Default value: DESC. Valid values:

  • ASC: ascending order
  • DESC: descending order
ASC
OrderBystringNo

The dimension by which to sort the results. Default value: execution_time. Valid values:

  • execution_time: sorts the results by query start time.
  • latency: sorts the results by query latency.
execution_time

Response parameters

ParameterTypeDescriptionExample
object
StartTimestring

The start time of the query.

2019-03-10T13:11Z
RequestIdstring

The ID of the request.

686BB8A6-BBA5-47E5-8A75-D2ADE433****
PageRecordCountinteger

The number of log entries returned on the current page.

1
TotalRecordCountinteger

The total number of returned log entries.

1
PageSizeinteger

The maximum number of log entries returned per page.

30
InstanceIdstring

The ID of the instance.

r-bp10n********
Enginestring

The database engine that the instance runs.

Redis
PageNumberinteger

The page number of the returned page.

1
Itemsarray<object>

The slow query log entries.

LogRecordsobject
Accountstring

The ID of the account.

0
ElapsedTimelong

The amount of time consumed to execute the slow query statement. Unit: microseconds.

248
Commandstring

The slow query statement.

KEYS *
DBNamestring

The database name.

-1
ExecuteTimestring

The start time when the slow query statement was executed. The time is displayed in the YYYY-MM-DDTHH:mm:ssZ format.

2019-03-20T09:18:41Z
DataBaseNamestring

The database name. This parameter serves the same purpose as the DBName parameter. We recommend that you use the DBName parameter.

-1
NodeIdstring

The node ID.

r-bp1zxszhcgatnx****-db-0
AccountNamestring

The username of the account.

demo
IPAddressstring

The IP address of the client.

172.16.88.***

Examples

Sample success responses

JSONformat

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

Error codes

HTTP status codeError codeError messageDescription
400InvalidStartTime.MalformedThe Specified parameter StartTime is not valid.-
400InvalidEndTime.MalformedThe Specified parameter EndTime is not valid.The end time is invalid. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC. Example: 2011-06-11T16:00Z.
400InvalidStartTimeAndEndTime.MalformedThe end time must be later than the start time.
400InvalidPageSize.Malformed-
403IncorrectEngineVersionCurrent engine version does not support operations.The current Redis version does not support this operation. Please refer to the relevant documentation for this operation to understand the Redis version requirements for this operation.
403ServerBusyserver busy now, please retry later.-

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