Queries the audit logs of an ApsaraDB for Redis instance.
Operation Description
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.
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.
Operation | Access level | Resource type | Condition key | Association operation |
---|---|---|---|---|
kvstore:DescribeAuditRecords | READ |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
InstanceId | string | Yes | The ID of the ApsaraDB for Redis instance for which you want to query the audit log. | r-bp1zxszhcgatnx**** |
NodeId | string | No | The ID of the node on the instance. You can set this parameter to query the information about a specified node. Note | r-bp1zxszhcgatnx****-db-0 |
AccountName | string | No | The name of the account. By default, all accounts are queried. | demo |
DatabaseName | string | No | The name of the database. | 0 |
QueryKeywords | string | No | 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. NoteYou can specify only one keyword in each call. | maxclients |
HostAddress | string | No | The IP address of the client. By default, all client IP addresses are queried. | 127.0.0.1 |
PageSize | integer | No | The maximum number of log entries to return per page. | 30 |
PageNumber | integer | No | The page number of the page to return. | 1 |
StartTime | string | Yes | 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. | 2019-03-24T12:10:00Z |
EndTime | string | Yes | 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. NoteWe 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. | 2019-03-25T12:10:00Z |
Response parameters
Examples
Sample success responses
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. | - |
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. | 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. |
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. | - |
For a list of error codes, visit the Service error codes.