获取MongoDB实例慢日志列表
更新时间:2024-11-15
接口描述
获取MongoDB实例慢查询列表
权限说明
鉴权认证机制的详细内容请参见鉴权认证。
请求结构
JSON
1GET /v{version}/diagnosis/mongodb/slowlog/list?appId=appId
2&nodeId=nodeId
3&start=start
4&end=end
5&users=users
6&dbNames=dbNames
7&clientIps=clientIps
8&namespace=namespace
9&fingerprintMd5=fingerprintMd5
10&orderBy=orderBy
11&order=order
12&page=page
13&pageSize=pageSize HTTP/1.1
14Host: dbsc.bj.baidubce.com
15Authorization: authorization string
请求头域
除公共头域外,无其它特殊头域。
请求参数
参数名称 | 类型 | 必选 | 参数位置 | 描述 |
---|---|---|---|---|
version | string | 是 | Path参数 | API版本号 |
appId | string | 是 | Query参数 | 集群ID |
nodeId | string | 否 | Query参数 | 节点ID |
start | datetime | 是 | Query参数 | 开始时间 |
end | datetime | 是 | Query参数 | 结束时间 |
users | string | 否 | Query参数 | 数据库用户,多个以逗号分隔 |
dbNames | string | 否 | Query参数 | 数据库,多个以逗号分隔 |
clientIps | string | 否 | Query参数 | 客户端IP,多个以逗号分隔 |
namespace | string | 否 | Query参数 | 命令空间 |
fingerprintMd5 | string | 否 | Query参数 | SQL的归一化指纹的MD5值 |
orderBy | string | 否 | Query参数 | 排序字段,比如start,支持的排序字段可以参考响应参数中的MongoDBSlowLogDetail结构字段 |
order | string | 否 | Query参数 | 排序方式正序:asc倒序:desc |
page | integer | 否 | Query参数 | 分页,默认是1 |
pageSize | integer | 否 | Query参数 | 每页展示条数,默认是20 |
响应头域
无。
响应参数
参数名称 | 类型 | 描述 |
---|---|---|
logs | List |
全量日志列表 |
totalCount | integer |
日志总数 |
MongoDBSlowLogDetail
参数名称 | 类型 | 描述 |
---|---|---|
uuid | string | 命令唯一标识 |
clientIp | string | 客户端IP |
clientPort | integer | 客户端端口 |
user | string | 用户名称 |
connectionId | interge | 会话ID |
currentDB | string | 连接数据库名称 |
duration | integer | SQL执行时间,单位毫秒 |
start | datetime | SQL开始时间 |
end | datetime | SQL结束时间 |
fingerprint | string | 归一化SQL |
fingerprintMd5 | string | 归一化SQL指纹 |
query | string | SQL语句 |
sqlCommand | string | SQL命令类型,比如: select,create table等 |
scanRows | integer | 扫描行数 |
returnRows | integer | 返回行数 |
keyScanRows | integer | 索引扫描行数 |
resultLen | integer | 返回结果集大小 |
planSummary | string | 执行计划 |
namespace | string | 命名空间 |
请求示例
JSON
1GET /v1/diagnosis/mongodb/slowlog/list?appId=m-YPG8VL&nodeId=node-htILmc&start=2024-11-11T02:28:27Z&end=2024-11-11T02:58:27Z&page=1&pageSize=2&order=desc&orderBy=duration&users=__system&dbNames=local&fingerprintMd5=7be6218aa03b4226e7303e85c460608c&namespace=local.oplog.rs
2HOST: dbsc.bj.baidubce.com
3Content-Type: application/json
4Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
响应示例
JSON
1{
2 "logs": [
3 {
4 "clientIp": "",
5 "clientPort": 0,
6 "duration": 5010,
7 "start": "2024-11-11T02:30:02Z",
8 "end": "2024-11-11T02:30:07Z",
9 "user": "__system",
10 "currentDB": "local",
11 "query": "getMore { getMore: 15535168130, collection: \"oplog.rs\", maxTimeMS: 5000, term: 3, lastKnownCommittedOpTime: { ts: Timestamp 1731292197000|1, t: 3 } } originatingCommand: { find: \"oplog.rs\", filter: { ts: { $gte: Timestamp 1731292025000|1 } }, tailable: true, oplogReplay: true, awaitData: true, maxTimeMS: 60000, term: 3, readConcern: { afterOpTime: { ts: Timestamp 1731292025000|1, t: 2 } } }",
12 "uuid": "20241111103244.464749364_BDAYwnC",
13 "sqlCommand": "command",
14 "connectionId": 8,
15 "fingerprint": "command",
16 "fingerprintMd5": "7be6218aa03b4226e7303e85c460608c",
17 "returnRows": 0,
18 "scanRows": 0,
19 "keyScanRows": 0,
20 "resultLen": 451,
21 "planSummary": "COLLSCAN",
22 "namespace": "local.oplog.rs"
23 },
24 {
25 "clientIp": "",
26 "clientPort": 0,
27 "duration": 5009,
28 "start": "2024-11-11T02:30:02Z",
29 "end": "2024-11-11T02:30:07Z",
30 "user": "__system",
31 "currentDB": "local",
32 "query": "getMore { getMore: 14395218266, collection: \"oplog.rs\", maxTimeMS: 5000, term: 3, lastKnownCommittedOpTime: { ts: Timestamp 1731292197000|1, t: 3 } } originatingCommand: { find: \"oplog.rs\", filter: { ts: { $gte: Timestamp 1731292025000|1 } }, tailable: true, oplogReplay: true, awaitData: true, maxTimeMS: 60000, term: 3, readConcern: { afterOpTime: { ts: Timestamp 1731292025000|1, t: 2 } } }",
33 "uuid": "20241111103244.464113784_aEnfIcW",
34 "sqlCommand": "command",
35 "connectionId": 6,
36 "fingerprint": "command",
37 "fingerprintMd5": "7be6218aa03b4226e7303e85c460608c",
38 "returnRows": 0,
39 "scanRows": 0,
40 "keyScanRows": 0,
41 "resultLen": 451,
42 "planSummary": "COLLSCAN",
43 "namespace": "local.oplog.rs"
44 }
45 ],
46 "totalCount": 366
47}