查询MongoDB实例的审计日志。
接口说明
- 调用本接口时,实例的审计日志须处于开通状态,否则返回的审计日志内容为空。 
- 本接口适用于规格类型为通用型本地盘版和独享型本地盘版实例。 
- 本接口限制每分钟调用 30 次,如超过这个限制会被限流,请勿高频调用。如需高频调用,请使用 Logstore,详情请参见管理 Logstore。 
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
 调试
        
            调试
        
    
授权信息
| 操作 | 访问级别 | 资源类型 | 条件关键字 | 关联操作 | 
| dds:DescribeAuditRecords | get | *dbinstance 
 | 无 | 无 | 
请求参数
| 名称 | 类型 | 必填 | 描述 | 示例值 | 
| DBInstanceId | string | 是 | 实例 ID。 说明 
 当本参数传入的是分片集群实例 ID 时,还需要传入 NodeId 参数。 | dds-bp12c5b040dc**** | 
| NodeId | string | 否 | 分片集群实例中 Mongos 节点 ID 或 Shard 节点 ID。 说明 
 当 DBInstanceId 参数传入的是分片集群实例 ID 时,本参数才可用。 | d-bp128a003436**** | 
| StartTime | string | 是 | 查询开始时间,格式为yyyy-MM-ddTHH:mm:ssZ(UTC 时间)。 | 2019-03-13T12:11:14Z | 
| EndTime | string | 是 | 查询结束时间,必须晚于查询开始时间,格式为yyyy-MM-ddTHH:mm:ssZ(UTC 时间)。 说明 
 查询结束时间距查询开始时间不得超过 24 个小时,超过则调用失败。 | 2019-03-13T13:11:14Z | 
| Database | string | 否 | 数据库名,默认为所有数据库。 | database**** | 
| User | string | 否 | 数据库账号,默认为所有账号。 | test | 
| Form | string | 否 | 审计记录返回的展示类型,取值: 
 说明 
 File 参数已废弃 | Stream | 
| QueryKeywords | string | 否 | 关键字查询。多个关键字以空格分隔,不超过 10 个关键字。 | slow | 
| LogicalOperator | string | 否 | 关键字搜索的逻辑操作, 默认值为 and。 | and | 
| PageSize | integer | 否 | 每页记录数。取值:30(默认值)、50、100。 | 30 | 
| PageNumber | integer | 否 | 页码。大于 0,且不超过 Integer 的最大值,默认值为 1。 | 1 | 
| OrderType | string | 否 | 按时间的升降序对查询到的慢日志进行排序。取值: 
 | asc | 
返回参数
| 名称 | 类型 | 描述 | 示例值 | 
| object | 总记录数。 | ||
| TotalRecordCount | integer | 总记录数。 | 40 | 
| PageRecordCount | integer | 当前页最大记录数。 | 30 | 
| RequestId | string | 请求 ID。 | 3278BEB8-503B-4E46-8F7E-D26E040C9769 | 
| PageNumber | integer | 页码。 | 1 | 
| Items | object | ||
| SQLRecord | array<object> | 审计日志详情列表。 | |
| object | 实例信息。 | ||
| HostAddress | string | 客户端 IP 地址。 | 11.xxx.xxx.xxx | 
| TableName | string | MongoDB 的集合名称。 | C1 | 
| ReturnRowCounts | integer | 返回记录数。 | 2 | 
| DBName | string | 数据库名。 | test123 | 
| ExecuteTime | string | 该语句执行的时间,格式为yyyy-MM-ddTHH:mm:ssZ(UTC 时间)。 | 2019-03-11T03:30:27Z | 
| ThreadID | string | 线程 ID。 | 140682188297984 | 
| TotalExecutionTimes | integer | 消耗时间,单位为微秒。 | 700 | 
| Syntax | string | 执行语句。 | { \"atype\" : \"createCollection\", \"param\" : { \"ns\" : \"123.test1\" }, \"result\": \"OK\" } | 
| AccountName | string | 数据库账号名。 | test | 
示例
正常返回示例
JSON格式
{
  "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"
      }
    ]
  }
}错误码
| HTTP status code | 错误码 | 错误信息 | 描述 | 
|---|---|---|---|
| 400 | InvalidStartTime.Format | Specified start time is not valid. | 指定的开始时间无效。 | 
| 400 | InvalidEndTime.Format | Specified end time is not valid. | |
| 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. | |
| 403 | ConcurrentTaskExceeded | Concurrent task exceeding the allowed amount. | 
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。