Queries the audit log of an ApsaraDB for Redis instance.

This operation can be called up to 100 times per minute. For more information about how to query the audit log in the ApsaraDB for Redis console, see Query the audit log.

Before you call this operation, make sure that the following requirements are met:

  • ApsaraDB for Redis instances of Community Edition or performance-enhanced instances of Enterprise Edition are used.
  • The engine version of the instance is Redis 4.0 or later.

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 Yes DescribeAuditRecords

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

InstanceId String Yes r-bp1zxszhcgatnx****

The ID of the ApsaraDB for Redis instance for which you want to query the audit log.

StartTime String Yes 2019-03-24T12:10:00Z

The start of the time range that is specified to query the audit log. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

EndTime String Yes 2019-03-25T12:10:00Z

The end of the time range that is specified to query the audit log. The end time must be later than the start time. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

Note We recommend that you set a time range of 10 minutes or less because the audit log contains a great number of entries. Do not specify a time range that is longer than one day.
HostAddress String No 127.0.0.1

The IP address of the client. By default, all client IP addresses are queried.

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

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

Note
  • This parameter is available for only read/write splitting or cluster instances of ApsaraDB for Redis.
  • You can call the DescribeLogicInstanceTopology operation to query node IDs.
AccountName String No demo

The name of the account. By default, all accounts are queried.

DatabaseName String No 0

The name of the database.

QueryKeywords String No maxclients

The keyword based on which the audit log is queried. You can pass a command as a keyword to query log data for the specified command. By default, all commands are queried.

Note You can specify only one keyword in each call.
PageSize Integer No 30

The maximum number of log entries to return per page.

PageNumber Integer No 1

The page number of the page to return.

RegionId String No cn-hangzhou

The region ID of the instance.

Response parameters

Parameter Type Example Description
Items Array of SQL

The collection of returned audit log entries.

SQL
AccountName String demo

The name of the account.

DatabaseName String demo

The name of the database.

ExecuteTime String 2019-03-25T03:22:08Z

The time when the command was run.

HostAddress String 127.0.0.1

The client IP address.

IPAddress String 192.16.100.***

The IP address.

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

The ID of the node.

Note A specific node ID is returned only if a cluster or read/write splitting instance is used.
SQLText String CONFIG GET maxmemory

The command that was run.

SQLType String non_read_write

The type of command.

TotalExecutionTimes String 0

The amount of time that is consumed to run the command.

StartTime String 2019-03-24T12:10:00Z

The start of the time range that is specified to query the audit log.

EndTime String 2019-03-25T12:10:00Z

The end of the time range that is specified to query the audit log.

PageNumber Integer 1

The page number of the page returned.

PageSize Integer 30

The maximum number of log entries returned on each page.

RequestId String 9F5EB478-824E-4AC4-8D2B-58F31A02****

The ID of the request.

InstanceName String r-bp1zxszhcgatnx****

The name of the ApsaraDB for Redis instance.

TotalRecordCount Integer 22222

The total number of log entries returned.

Examples

Sample requests

https://r-kvstore.aliyuncs.com/?Action=DescribeAuditRecords
&InstanceId=r-bp1zxszhcgatnx****
&StartTime=2019-03-24T12:10:00Z
&EndTime=2019-03-25T12:10:00Z
&<Common request parameters>

Sample success responses

XML format

<DescribeAuditRecordsResponse>
      <Items>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:08Z</ExecuteTime>
                  <SQLText>CONFIG GET band-width</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:08Z</ExecuteTime>
                  <SQLText>CONFIG GET maxmemory</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:08Z</ExecuteTime>
                  <SQLText>CONFIG GET maxclients</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:08Z</ExecuteTime>
                  <SQLText>CONFIG GET qps</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:03Z</ExecuteTime>
                  <SQLText>CONFIG GET qps</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:03Z</ExecuteTime>
                  <SQLText>CONFIG GET maxclients</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
            <SQL>
                  <TotalExecutionTimes>0</TotalExecutionTimes>
                  <DatabaseName>0</DatabaseName>
                  <HostAddress>127.0.0.1</HostAddress>
                  <ExecuteTime>2019-03-25T03:22:03Z</ExecuteTime>
                  <SQLText>CONFIG GET maxmemory</SQLText>
                  <AccountName>0</AccountName>
                  <SQLType>non_read_write</SQLType>
            </SQL>
      </Items>
      <TotalRecordCount>36559</TotalRecordCount>
      <PageNumber>1</PageNumber>
      <PageSize>30</PageSize>
      <RequestId>9F5EB478-824E-4AC4-8D2B-58F31A02****</RequestId>
      <EndTime>2019-03-25T12:10:00Z</EndTime>
      <StartTime>2019-03-24T12:10:00Z</StartTime>
      <InstanceName>r-bp1zxszhcgatnx****</InstanceName>
</DescribeAuditRecordsResponse>

JSON format

{
    "Items": {
        "SQL": [
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:08Z",
                "SQLText": "CONFIG GET band-width",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:08Z",
                "SQLText": "CONFIG GET maxmemory",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:08Z",
                "SQLText": "CONFIG GET maxclients",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:08Z",
                "SQLText": "CONFIG GET qps",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:03Z",
                "SQLText": "CONFIG GET qps",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:03Z",
                "SQLText": "CONFIG GET maxclients",
                "AccountName": "0",
                "SQLType": "non_read_write"
            },
            {
                "TotalExecutionTimes": "0",
                "DatabaseName": "0",
                "HostAddress": "127.0.0.1",
                "ExecuteTime": "2019-03-25T03:22:03Z",
                "SQLText": "CONFIG GET maxmemory",
                "AccountName": "0",
                "SQLType": "non_read_write"
            }
        ]
    },
    "TotalRecordCount": 36559,
    "PageNumber": 1,
    "PageSize": 30,
    "RequestId": "9F5EB478-824E-4AC4-8D2B-58F31A02****",
    "EndTime": "2019-03-25T12:10:00Z",
    "StartTime": "2019-03-24T12:10:00Z",
    "InstanceName": "r-bp1zxszhcgatnx****"
}

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 UTC. Example: 2011-06-11T16:00Z.

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