Queries audit logs of an ApsaraDB for Redis instance.
This operation can be called up to 100 times per minute. For more information about how to query audit logs in the ApsaraDB for Redis console, see Query audit logs.
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 Enhanced Edition are used.
- The engine version of the instance is Redis 4.0 or later.
Debugging
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 instance for which you want to query audit logs. |
StartTime | String | Yes | 2019-03-24T12:10:00Z |
The start of the time range to query. 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 to query. 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 Due to the large number of audit logs, we recommend that you set a time range of 10
minutes or less for queries. The maximum time range is one day.
|
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-bp1zxszhcgatnx****-db-0 |
The ID of the node on the instance. You can set the NodeId parameter to query the monitoring information of a specified node. Note
|
AccountName | String | No | demo |
The name of the account. By default, the system queries audit logs of all accounts. |
DatabaseName | String | No | 0 |
The name of the database. |
QueryKeywords | String | No | maxclients |
The keyword based on which audit logs are queried. You can pass a command as a keyword to query audit logs of this command. By default, the system queries audit logs of all commands that have been run. Note You can specify only one keyword in each call.
|
PageSize | Integer | No | 30 |
The maximum number of logs to return on each page. |
PageNumber | Integer | No | 1 |
The page number of the returned page. |
RegionId | String | No | cn-hangzhou |
The ID of the region where the instance is deployed. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
Items | Array of SQL |
The collection of returned audit logs. |
|
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 | 192.16.100.*** |
The IP address. |
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 time of the query. |
EndTime | String | 2019-03-25T12:10:00Z |
The end of the time range when audit logs are queried. |
PageNumber | Integer | 1 |
The page number of the returned page. |
PageSize | Integer | 30 |
The maximum number of returned logs on each page. |
RequestId | String | 9F5EB478-824E-4AC4-8D2B-58F31A02**** |
The ID of the request. |
InstanceName | String | r-bp1zxszhcgatnx**** |
The name of the instance. |
TotalRecordCount | Integer | 22222 |
The total number of returned logs. |
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 GMT. Example: 2011-06-11T16:00Z. |
For a list of error codes, visit the API Error Center.