You can call this operation to query audit logs of an ApsaraDB for Redis instance.

For more information about how to perform the corresponding operation in the console, see Query audit 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 dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String No DescribeAuditRecords

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

InstanceId String Yes r-bp1xxxxxxxxxxxxx

The ID of the instance for which you want to query audit logs.

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

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format.

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

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The end time must be later than the start time.

HostAddress String No 127.0.0.1

The IP address of the client. By default, the system queries audit logs of all IP addresses.

NodeId String No r-bp1xxxxxxxxxxxxx-db-0

The ID of the child node in the cluster.

AccountName String No demo

The name of the account. By default, the system queries audit logs of all accounts.

DatabaseName String No demo

The name of the database.

QueryKeywords String No maxclients

The keyword based on which audit logs are queried. You can specify a command as a keyword. By default, the system queries audit logs of all commands that have been run.

Note You can specify only one keyword at a time.
PageSize Integer No 30

The number of entries to return on each page.

PageNumber Integer No 1

The number of the page to return.

RegionId String No cn-hangzhou

The ID of the region.

Response parameters

Parameter Type Example Description
Items Array

The collection of audit logs returned.

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 IP address of the client.

IPAddress String xxx.xxx.xxx.100

The IP address of the instance.

SQLText String CONFIG GET maxmemory

The command that was run.

SQLType String non_read_write

The type of the command.

TotalExecutionTimes String 0

The amount of time that it took to run the command.

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

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

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

The end of the time range where audit logs were queried.

PageNumber Integer 1

The page number of the returned page.

PageSize Integer 30

The number of entries returned per page.

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

The ID of the request.

InstanceName String r-bp1xxxxxxxxxxxxx

The names of the instance.

TotalRecordCount Integer 22222

The total number of entries returned.

Examples

Sample requests

https://r-kvstore.aliyuncs.com/
? Action=DescribeAuditRecords
&InstanceId=r-bp1xxxxxxxxxxxxx
&StartTime=2018-12-04T12:10:00Z
&EndTime=2018-12-30T12: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-58F31A028E7B</RequestId>
	  <EndTime>2019-03-25T12:10:00Z</EndTime>
	  <StartTime>2019-03-24T12:10:00Z</StartTime>
	  <InstanceName>r-bp1xxxxxxxxxxxxx</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-58F31A028E7B",
	"EndTime": "2019-03-25T12:10:00Z",
	"StartTime": "2019-03-24T12:10:00Z",
	"InstanceName": "r-bp1xxxxxxxxxxxxx"
}

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

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