Queries the audit logs of an ApsaraDB for Tair (Redis® OSS-Compatible) database instance.
Operation description
When you call this operation, the audit log feature must be enabled for the instance. For more information, see ModifyAuditLogConfig.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
kvstore:DescribeAuditRecords |
get |
*DBInstance
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
Yes |
The ID of the instance. |
r-bp1zxszhcgatnx**** |
| NodeId |
string |
No |
The ID of the node in the instance. Specify this parameter to query the monitoring information of a specific node. Note
|
r-bp1zxszhcgatnx****-db-0 |
| AccountName |
string |
No |
The name of the account. If you do not specify this parameter, the audit logs of all accounts are queried. |
demo |
| DatabaseName |
string |
No |
The database in the instance. If you do not specify this parameter, the audit logs of all databases are queried. Valid values: 0 to 255. For example, 0 indicates database 0. |
0 |
| QueryKeywords |
string |
No |
The keyword used to query audit logs based on a specific command. By default, the audit logs of all executed commands are queried. Note
You can specify only one keyword. |
maxclients |
| HostAddress |
string |
No |
The IP address of the client. If you do not specify this parameter, the audit logs of all IP addresses are queried. |
127.0.0.1 |
| PageSize |
integer |
No |
The maximum number of entries to return on each page. Valid values:
|
30 |
| PageNumber |
integer |
No |
The page number of the page to return. |
1 |
| StartTime |
string |
Yes |
The start time of the query. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. |
2019-03-24T12:10:00Z |
| EndTime |
string |
Yes |
The end time of the 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
Because audit logs contain a large number of entries, specify a time range of up to 10 minutes and a maximum of 1 day. |
2019-03-25T12:10:00Z |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| EndTime |
string |
The end time of the query. The time is in the YYYY-MM-DDTHH:mm:ssZ format and displayed in UTC. |
2019-03-25T12:10:00Z |
| StartTime |
string |
The start time of the query. The time is in the YYYY-MM-DDTHH:mm:ssZ format and displayed in UTC. |
2019-03-24T12:10:00Z |
| RequestId |
string |
The ID of the request. |
9F5EB478-824E-4AC4-8D2B-58F31A02**** |
| InstanceName |
string |
The name of the instance. |
r-bp1zxszhcgatnx**** |
| TotalRecordCount |
integer |
The total number of entries. |
22222 |
| PageNumber |
integer |
The page number of the page to return. |
1 |
| PageSize |
integer |
The maximum number of entries to return on each page. |
30 |
| Items |
object |
||
| SQL |
array<object> |
The collection of audit log entries. |
|
|
object |
|||
| HostAddress |
string |
The IP address of the client. |
127.0.0.1 |
| SQLText |
string |
The command record. |
CONFIG GET maxmemory |
| DatabaseName |
string |
The name of the database. |
demo |
| SQLType |
string |
The type of the command. |
non_read_write |
| ExecuteTime |
string |
The execution time. The time is in the YYYY-MM-DDTHH:mm:ssZ format and displayed in UTC. |
2019-03-25T03:22:08Z |
| TotalExecutionTimes |
string |
The execution duration. |
0 |
| NodeId |
string |
The ID of the node. Note
This parameter is returned only when the instance uses the cluster or read/write splitting architecture. |
r-bp1zxszhcgatnx****-db-0 |
| AccountName |
string |
The name of the account. |
demo |
| IPAddress |
string |
The IP address. |
192.16.100.*** |
Examples
Success response
JSON format
{
"EndTime": "2019-03-25T12:10:00Z",
"StartTime": "2019-03-24T12:10:00Z",
"RequestId": "9F5EB478-824E-4AC4-8D2B-58F31A02****",
"InstanceName": "r-bp1zxszhcgatnx****",
"TotalRecordCount": 22222,
"PageNumber": 1,
"PageSize": 30,
"Items": {
"SQL": [
{
"HostAddress": "127.0.0.1",
"SQLText": "CONFIG GET maxmemory",
"DatabaseName": "demo",
"SQLType": "non_read_write",
"ExecuteTime": "2019-03-25T03:22:08Z",
"TotalExecutionTimes": "0",
"NodeId": "r-bp1zxszhcgatnx****-db-0",
"AccountName": "demo",
"IPAddress": "192.16.100.***"
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | IncorrectDBInstance.NotSupported | This instance do not support log audit. | This instance does not support audit log related services |
| 400 | InvalidEndTime.Invalid | pecified end time is before this service active time. | |
| 400 | InvalidStartTime.Malformed | The Specified parameter StartTime is not valid. | |
| 400 | InvalidEndTime.Malformed | The Specified parameter EndTime is not valid. | |
| 400 | InvalidPageSize.Malformed | The specified parameter PageSize is not valid. | |
| 400 | InvalidPageNumbers.Malformed | Specified page number is not valid. | |
| 400 | InvalidQueryTime.Format | Specified query time is not valid. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.