获取MongoDB实例慢日志列表
更新时间:2024-11-15
接口描述
获取MongoDB实例慢查询列表
权限说明
鉴权认证机制的详细内容请参见鉴权认证。
请求结构
GET /v{version}/diagnosis/mongodb/slowlog/list?appId=appId
&nodeId=nodeId
&start=start
&end=end
&users=users
&dbNames=dbNames
&clientIps=clientIps
&namespace=namespace
&fingerprintMd5=fingerprintMd5
&orderBy=orderBy
&order=order
&page=page
&pageSize=pageSize HTTP/1.1
Host: dbsc.bj.baidubce.com
Authorization: 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 | 命名空间 |
请求示例
GET /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
HOST: dbsc.bj.baidubce.com
Content-Type: application/json
Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2017-11-21T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
响应示例
{
"logs": [
{
"clientIp": "",
"clientPort": 0,
"duration": 5010,
"start": "2024-11-11T02:30:02Z",
"end": "2024-11-11T02:30:07Z",
"user": "__system",
"currentDB": "local",
"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 } } }",
"uuid": "20241111103244.464749364_BDAYwnC",
"sqlCommand": "command",
"connectionId": 8,
"fingerprint": "command",
"fingerprintMd5": "7be6218aa03b4226e7303e85c460608c",
"returnRows": 0,
"scanRows": 0,
"keyScanRows": 0,
"resultLen": 451,
"planSummary": "COLLSCAN",
"namespace": "local.oplog.rs"
},
{
"clientIp": "",
"clientPort": 0,
"duration": 5009,
"start": "2024-11-11T02:30:02Z",
"end": "2024-11-11T02:30:07Z",
"user": "__system",
"currentDB": "local",
"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 } } }",
"uuid": "20241111103244.464113784_aEnfIcW",
"sqlCommand": "command",
"connectionId": 6,
"fingerprint": "command",
"fingerprintMd5": "7be6218aa03b4226e7303e85c460608c",
"returnRows": 0,
"scanRows": 0,
"keyScanRows": 0,
"resultLen": 451,
"planSummary": "COLLSCAN",
"namespace": "local.oplog.rs"
}
],
"totalCount": 366
}