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.
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 |
---|---|---|---|---|
dds:DescribeAuditRecords | READ |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
DBInstanceId | string | Yes | The ID of the instance. NoteIf 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 whose parameter modification records you want to query in the instance. If the instance is a sharded cluster instance, you must specify this parameter. NoteThis parameter is valid only when you specify 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 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 yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC. NoteThe 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 account of the database. If you do not specify this parameter, this operation returns records of all accounts. | test |
Form | string | No | The form of the audit log that the operation returns. Default value: File. Valid values:
| Stream |
QueryKeywords | string | No | The keywords that are used for queries. Separate multiple keywords with spaces. The maximum number of keywords is 10. | slow |
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 number of the page to return. Pages start from page 1. Valid values: any non-zero positive integer. 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.