查询会话列表
更新时间:2026-01-08
查询会话列表
接口描述
本接口用于查询会话列表。
请求结构
Plain Text
1GET /v{version}/ddc/ob/instance/{instanceId}/tenant/{tenantId}/sessions HTTP/1.1
2Host: ddc.bj.baidubce.com
3Authorization: authorization string
请求头域
除公共头域外,无其它特殊头域。
请求参数
| 参数名称 | 类型 | 是否必选 | 参数位置 | 描述 |
|---|---|---|---|---|
| version | String | 是 | URL参数 | API版本号。 |
| instanceId | String | 是 | URL参数 | 集群ID。 |
| tenantId | String | 是 | URL参数 | 租户ID。 |
| status | String | 否 | Query参数 | 会话状态。 |
| sqlText | String | 否 | Query参数 | SQL语句 |
| clientIp | String | 否 | Query参数 | 客户端ip |
| serverIp | String | 否 | Query参数 | 服务器ip |
| users | String | 否 | Query参数 | 数据库用户名。示例: ["test_user"] |
响应头域
除公共头域外,无其它特殊头域。
响应参数
| 参数名称 | 类型 | 描述 |
|---|---|---|
| totalSessionCount | Long | 总会话数量 |
| activeSessionCount | Long | 活跃会话数量 |
| idleSessionCount | Long | SLEEP状态会话数量 |
| obVersion | String | OceanBase数据库版本 |
| sessionList | List<Session> | 所有会话详细信息 |
| statisticsResponse | StatisticsResponse | 会话统计对象 |
Session
| 参数名称 | 类型 | 描述 |
|---|---|---|
| sqlText | String | sql文本 |
| tenantId | String | 租户ID |
| database | String | 数据库名称 |
| user | String | 会话所属用户 |
| executeTime | Long | 执行时间,单位:ms |
| cpuTime | Long | cpu使用时间,单位:ms |
| serverIp | String | 服务器IP地址 |
| clientIp | String | 客户端IP地址 |
| sessionId | Long | 会话ID |
| proxySessId | String | 代理会话ID |
| command | String | 会话命令。Query:查询,Sleep:休眠 |
| status | String | 会话状态。ACTIVE:活跃,IDLE:空闲 |
| sqlId | String | sqlId |
| traceId | String | traceId |
| planId | Long | 执行计划id |
| dynamicSql | Boolean | 是否动态sql |
| topInfo | String | 用户执行pL场景的sql的话,最终执行的sql文本会返回在topInfo这个字段里面 |
StatisticsResponse
| 参数名称 | 类型 | 描述 |
|---|---|---|
| idleSessionCount | Long | SLEEP状态会话数量 |
| activeSessionCount | Long | 活跃会话数量 |
| totalSessionCount | Long | 总会话数量 |
| userStatistics | List<Statistics> | 用户维度会话统计 |
| sourceStatistics | List<Statistics> | 来源维度统计 |
| dataBaseStatistics | List<Statistics> | 数据库维度统计 |
Statistics
| 参数名称 | 类型 | 描述 |
|---|---|---|
| metricValue | String | 指标值(用户维度如用户名,来源维度如客户端ip,数据库维度如数据库名) |
| activeCount | Long | 活跃数量 |
| totalCount | Long | 总数量 |
| type | String | 类型(用户维度如user,来源维度如client,数据库维度如database) |
请求示例
Plain Text
1GET http://ddc.bj.baidubce.com/v1/ddc/ob/instance/ob7cpcvj73o934/tenant/t7cpiwq9ketb4/sessions?status=&sqlText=&clientIp=null&serverIp=null&users=
2Host: ddc.bj.baidubce.com
3Authorization: bce-auth-v1/f81d3b34e48048fbb2634dc7882d7e21/2015-08-11T04:17:29Z/3600/host/74c506f68c65e26c633bfa104c863fffac5190fdec1ec24b7c03eb5d67d2e1de
响应示例
Plain Text
1HTTP/1.1 200 OK
2Content-Type: application/json;charset=UTF-8
3Date: Wed, 08 Jul 2015 03:28:11 GMT
4x-bce-request-id: d8752367-38e8-45e4-b4c7-e53be3137ce5
5Server: BWS
6{
7 "totalSessionCount": 1,
8 "activeSessionCount": 0,
9 "idleSessionCount": 1,
10 "sessionList": [
11 {
12 "tenantId": "t7cpiwq9ketb4",
13 "database": "clltestdb",
14 "user": "cll",
15 "executeTime": 638,
16 "cpuTime": 0,
17 "serverIp": "10.146.1.232",
18 "clientIp": "172.16.0.4",
19 "sessionId": 3221505552,
20 "proxySessId": "761673383112017529",
21 "command": "Sleep",
22 "status": "IDLE",
23 "sqlId": ""
24 }
25 ],
26 "statisticsResponse": {
27 "idleSessionCount": 0,
28 "activeSessionCount": 0,
29 "totalSessionCount": 0,
30 "userStatistics": [
31 {
32 "metricValue": "cll",
33 "activeCount": 0,
34 "totalCount": 1,
35 "type": "user"
36 }
37 ],
38 "sourceStatistics": [
39 {
40 "metricValue": "172.16.0.4",
41 "activeCount": 0,
42 "totalCount": 1,
43 "type": "client"
44 }
45 ],
46 "dataBaseStatistics": [
47 {
48 "metricValue": "clltestdb",
49 "activeCount": 0,
50 "totalCount": 1,
51 "type": "database"
52 }
53 ]
54 },
55 "obVersion": "4.3.5.5"
56}
评价此篇文章
