Overview
You can call this API to query the statistics of all sessions in a specified OceanBase Cloud instance and tenant, and group the statistics by SQL ID. You can analyze the execution of different SQL statements, such as the number of active sessions and user sources, to monitor performance and troubleshoot issues.
API details
Constraints
The caller must have an AccessKey for accessing multi-cloud APIs. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
GET /api/v2/instances/{instanceId}/tenants/{tenantId}/sessions/groupBySqlId
Request parameters
Path parameters
| Parameter |
Type |
Required |
Description |
Example value |
| instanceId |
string |
Yes |
The ID of the OceanBase Cloud instance. |
obcluster-***** |
| tenantId |
string |
Yes |
The ID of the tenant. |
t4louaeei**** |
Query parameters
| Parameter |
Type |
Required |
Description |
Example value |
| requestId |
string |
Yes |
The request ID, which is used to track the request. |
dc302d76-66b5-48d8-ab53-a035******** |
| status |
string |
No |
The status of the session. |
N/A |
| sqlText |
string |
No |
The text of the SQL statement, which is used for fuzzy matching. |
SELECT * FROM users WHERE id = 1 |
| clientIp |
string |
No |
The IP address of the client, which is used to filter sessions from a specific client. |
N/A |
| serverIp |
string |
No |
The IP address of the server, which is used to filter sessions running on a specific server. |
N/A |
| users |
string |
No |
The username, which is used to filter sessions of a specific user. |
N/A |
| sortField |
string |
No |
The field by which the results are sorted. |
N/A |
| sortOrder |
string |
No |
The sort order. Valid values: ASC (ascending) or DESC (descending). |
N/A |
| mergeDynamicSql |
boolean |
No |
Specifies whether to merge dynamic SQL. If you set this parameter to true, parameterized SQL statements are merged and statistics are aggregated. |
N/A |
Response parameters
| Parameter |
Type |
Description |
| requestId |
string |
The request ID, which is the same as the requestId parameter. |
| data |
array |
The list of session statistics grouped by SQL ID. |
| data[].sqlId |
string |
The unique ID of the SQL statement. |
| data[].sqlText |
string |
The text of the SQL statement. |
| data[].sessionCount |
integer |
The number of active sessions that execute the SQL statement. |
| data[].userCount |
integer |
The number of different users that execute the SQL statement. |
| data[].clientIpCount |
integer |
The number of different client IP addresses that execute the SQL statement. |
| data[].serverIpCount |
integer |
The number of different server IP addresses that execute the SQL statement. |
| server |
string |
The IP address of the server that processes the request. |
Examples
Request example
curl -X GET \
-H "Content-Type: application/json" \
-u '<your ak:sk>' \
"https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/sessions/groupBySqlId?requestId={requestId}"
Response example
{
"requestId": "{requestId}",
"data": [
{
"sqlId": "xxxxxx",
"sqlText": "SELECT * FROM t1 WHERE id = ?",
"sessionCount": 5,
"userCount": 3,
"clientIpCount": 2,
"serverIpCount": 1
},
{
"sqlId": "yyyyyy",
"sqlText": "UPDATE t2 SET name = ? WHERE id = ?",
"sessionCount": 2,
"userCount": 1,
"clientIpCount": 1,
"serverIpCount": 1
}
],
"server": "xxx.xxx.x.xxx:xxxx"
}