Queries the audit logs of an ApsaraDB for MongoDB instance.
Operation description
- When you call this operation, ensure that the audit log feature of the instance is enabled. Otherwise, the operation returns an empty audit log.
- This operation is applicable only to general-purpose local-disk and dedicated local-disk instances.
- You can call this operation up to 30 times per minute. To call this operation at a higher frequency, use a Logstore. For more information, see Manage a Logstore.
Debugging
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:
- For mandatory resource types, indicate with a prefix of * .
- 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 | Associated operation |
---|---|---|---|---|
dds:DescribeAuditRecords | get | *dbinstance acs:dds:{#regionId}:{#accountId}:dbinstance/{#dbinstanceId} |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
DBInstanceId | string | Yes | The instance ID. Note
If you set this parameter to the ID of a sharded cluster instance, you must also specify the NodeId parameter.
| dds-bp12c5b040dc**** |
NodeId | string | No | The ID of the mongos node or shard node in the instance. Note
This parameter takes effect only when you set the DBInstanceId parameter to the ID of a sharded cluster instance.
| d-bp128a003436**** |
StartTime | string | Yes | The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. | 2019-03-13T12:11:14Z |
EndTime | string | Yes | The end of the time range to query. The end time must be later than the start time. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. Note
The end time must be within 24 hours from the start time. Otherwise, the query fails.
| 2019-03-13T13:11:14Z |
Database | string | No | The name of the database to be queried. By default, all databases are queried. | database**** |
User | string | No | The user of the database. If you do not specify this parameter, this operation returns records of all users. | test |
Form | string | No | The form of the audit log that the operation returns. Valid values:
| Stream |
QueryKeywords | string | No | The keywords used for query. You can enter up to 10 keywords at a time. If you enter multiple keywords, separate the keywords with spaces. | slow |
LogicalOperator | string | No | The logical relationship between multiple keywords. Valid values:
| and |
PageSize | integer | No | The number of entries to return per page. Default value: 30. Valid values: 30, 50, and 100. | 30 |
PageNumber | integer | No | The page number of the page to return. The valid value must be a positive integer that does not exceed the maximum value of the INTEGER data type. Default value: 1. | 1 |
OrderType | string | No | The order of time in which the log entries to return are sorted. Valid values:
| asc |
Response parameters
Examples
Sample success responses
JSON
format
{
"TotalRecordCount": 40,
"PageRecordCount": 30,
"RequestId": "3278BEB8-503B-4E46-8F7E-D26E040C9769",
"PageNumber": 1,
"Items": {
"SQLRecord": [
{
"HostAddress": "11.xxx.xxx.xxx",
"TableName": "C1",
"ReturnRowCounts": 2,
"DBName": "test123",
"ExecuteTime": "2019-03-11T03:30:27Z",
"ThreadID": "140682188297984",
"TotalExecutionTimes": 700,
"Syntax": "{ \\\"atype\\\" : \\\"createCollection\\\", \\\"param\\\" : { \\\"ns\\\" : \\\"123.test1\\\" }, \\\"result\\\": \\\"OK\\\" }",
"AccountName": "test"
}
]
}
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidStartTime.Format | Specified start time is not valid. | The specified start time is invalid. |
400 | InvalidEndTime.Format | Specified end time is not valid. | The specified EndTime parameter is invalid. Specify a valid end time point in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC. The end time must be later than the start time. |
400 | InvalidEndTime.Invalid | Specified end time is before this service active time. | - |
400 | InvalidParameterCombination | The end time must be greater than the start time. | - |
400 | InvalidQueryKeyword.Format | Specified Query Keyword is not valid. | - |
400 | InvalidDatabase.Format | Specified Database is not valid. | - |
400 | InvalidQueryTime.Format | Specified query time is not valid. | - |
403 | IncorrectSQLLogActiveStatus | Current DB instance SQL log active status does not support this operation. | - |
403 | LogApiFrequencyExceeded | Exceeding the allowed frequency of log api. | Maximum number of log API operations exceeded. |
403 | ConcurrentTaskExceeded | Concurrent task exceeding the allowed amount. | - |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2024-01-22 | The Error code has changed. The request parameters of the API has changed | View Change Details |