This topic describes how to use the API to get details of a tenant session based on the session ID.
API call
If you set a password, you must authenticate. For more information, see API hybrid encryption.
Request path
GET /api/v1/tenant/:name/sessions/:sessionId
Request parameters
Parameter |
Type |
Required |
Example value |
Description |
|---|---|---|---|---|
| name | string | Yes | t1 | The name of the tenant. This parameter is specified in the path. |
| sessionId | string | Yes | 12345 | The session ID. This parameter is specified in the path. |
Response
Parameter |
Type |
Description |
|---|---|---|
| successful | bool | Indicates whether the request was successful. |
| timestamp | time.Time | The timestamp when the server completed the request. |
| duration | int | The time taken by the server to process the request, in milliseconds. |
| status | int | The HTTP status code. |
| traceId | string | The trace ID of the request. |
| data | TenantSession | The details of the session. For more information, see the Data structure of TenantSession section below. |
| error | ApiError | The error information, which includes the following fields:
|
Data structure of TenantSession:
Parameter |
Type |
Description |
|---|---|---|
| id | int64 | The session ID. |
| svr_ip | string | The IP address of the server. |
| svr_port | int64 | The port number of the server. |
| sql_port | int64 | The SQL port number. |
| user | string | The username of the database user. |
| db | string | The name of the database. |
| tenant | string | The name of the tenant. |
| host | string | The client host address in the format of IP:port. |
| command | string | The command being executed. |
| time | float64 | The duration of the session, in seconds. |
| state | string | The session state. For example, "ACTIVE". |
| info | string | The SQL statement being executed. |
| proxy_sess_id | int64 | The proxy session ID. |
| proxy_ip | string | The IP address of the proxy. This parameter is resolved from the host when the ProxySessId is not empty. |
| action | string | The action. |
| module | string | The module. |
| client_info | string | The client information. |
| level | int64 | The level. |
| sample_percentage | int | The sampling percentage. |
| record_policy | string | The record policy. |
| sql_id | string | The SQL ID. |
| total_cpu_time | int64 | The total CPU time. |
| memory_usage | int64 | The memory usage. |
Examples
Request example
GET 10.10.10.1:2886/api/v1/tenant/t1/sessions/3221588508
Response example
{
"successful": true,
"timestamp": "2025-10-14T15:15:01.277047628+08:00",
"duration": 20,
"status": 200,
"traceId": "e6f64ba7f54e7a48",
"data": {
"id": 3221588508,
"svr_ip": "10.10.10.1",
"svr_port": 2882,
"sql_port": 2881,
"user": "root",
"db": "test",
"tenant": "t1",
"host": "127.0.0.1:12345",
"command": "Query",
"time": 12.005242,
"state": "ACTIVE",
"info": "SELECT * FROM users",
"proxy_sess_id": 0,
"proxy_ip": "",
"action": "",
"module": "",
"client_info": "",
"level": 1,
"sample_percentage": 10,
"record_policy": "SAMPLE_AND_SLOW_QUERY",
"sql_id": "C82D7414C2E9706348979FC0CE2199E9",
"total_cpu_time": 1000,
"memory_usage": 1024000
}
}
