All Products
Search
Document Center

ApsaraDB for MongoDB:DescribeAuditRecords

Last Updated:Mar 24, 2023

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.
OperationAccess levelResource typeCondition keyAssociation operation
dds:DescribeAuditRecordsREAD
  • MongoDB
    acs:dds:{#regionId}:{#accountId}:dbinstance/{#dbinstanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBInstanceIdstringYes

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****
NodeIdstringNo

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****
StartTimestringYes

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
EndTimestringYes

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
DatabasestringNo

The name of the database to be queried. By default, all databases are queried.

database****
UserstringNo

The account of the database. If you do not specify this parameter, this operation returns records of all accounts.

test
FormstringNo

The form of the audit log that the operation returns. Default value: File. Valid values:

  • File triggers the generation of audit logs. If this parameter is set to File, only common parameters are returned.
  • Stream: returns data streams.
Stream
QueryKeywordsstringNo

The keywords that are used for queries. Separate multiple keywords with spaces. The maximum number of keywords is 10.

slow
PageSizeintegerNo

The number of entries to return per page. Default value: 30. Valid values: 30, 50, and 100.

30
PageNumberintegerNo

The number of the page to return. Pages start from page 1. Valid values: any non-zero positive integer. Default value: 1.

1
OrderTypestringNo

The order of time in which the log entries to return are sorted. Valid values:

  • asc: The log entries are sorted by time in ascending order.
  • desc: The log entries are sorted by time in descending order.
asc

Response parameters

ParameterTypeDescriptionExample
object

The total number of returned entries.

TotalRecordCountinteger

The total number of returned entries.

40
PageRecordCountinteger

The maximum number of entries on the current page.

30
RequestIdstring

The ID of the request.

3278BEB8-503B-4E46-8F7E-D26E040C9769
PageNumberinteger

The page number of the returned page.

1
Itemsarray

An array that consists of the information of audit log entries.

object

The details of the instance.

HostAddressstring

The IP addresses of the client.

11.xxx.xxx.xxx
TableNamestring

The name of the collection.

C1
ReturnRowCountslong

The number of SQL audit log entries that are returned.

2
DBNamestring

The name of the database.

test123
ExecuteTimestring

The time when the statement was executed. The time is in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

2019-03-11T03:30:27Z
ThreadIDstring

The ID of the thread.

140682188297984
TotalExecutionTimeslong

The execution time of the statement. Unit: microseconds.

700
Syntaxstring

The statement that was executed.

{ \"atype\" : \"createCollection\", \"param\" : { \"ns\" : \"123.test1\" }, \"result\": \"OK\" }
AccountNamestring

The account of the database.

test

Examples

Sample success responses

JSONformat

{
  "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 codeError codeError messageDescription
400InvalidStartTime.FormatSpecified start time is not valid.The specified start time is invalid.
400InvalidEndTime.FormatSpecified 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.
400InvalidEndTime.InvalidSpecified end time is before this service active time.-
400InvalidParameterCombinationThe end time must be greater than the start time.-
400InvalidQueryKeyword.FormatSpecified Query Keyword is not valid.-
400InvalidDatabase.FormatSpecified Database is not valid.-
400InvalidQueryTime.FormatSpecified query time is not valid.-
403IncorrectSQLLogActiveStatusCurrent DB instance SQL log active status does not support this operation.-
403LogApiFrequencyExceededExceeding the allowed frequency of log api.Maximum number of log API operations exceeded.
403ConcurrentTaskExceededConcurrent task exceeding the allowed amount.-

For a list of error codes, visit the Service error codes.