All Products
Search
Document Center

ApsaraDB for MongoDB:DescribeAuditRecords

Last Updated:Sep 03, 2024

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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
DBInstanceIdstringYes

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

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

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
EndTimestringYes

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
DatabasestringNo

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

database****
UserstringNo

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

test
FormstringNo

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

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

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
LogicalOperatorstringNo

The logical relationship between multiple keywords. Valid values:

  • or
  • and (default value)
and
PageSizeintegerNo

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

30
PageNumberintegerNo

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
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
TotalRecordCountinteger

The total number of returned entries.

40
PageRecordCountinteger

The maximum number of entries on the current page.

30
RequestIdstring

The request ID.

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

The page number of the returned page.

1
Itemsarray<object>

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 follows the ISO 8601 standard 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 duration of the statement execution. 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.

Change history

Change timeSummary of changesOperation
2024-01-22The Error code has changed. The request parameters of the API has changedView Change Details