Querying Real-Time Sessions
Function
This API is used to query real-time sessions of a DB instance. Before calling this API:
- Learn how to authenticate this API.
- Obtain the required region and endpoint.
Constraints
This API is suitable only for nodes with CNs or DNs (primary or standby DNs).
Debugging
You can debug this API in API Explorer.
URI
POST /v3/{project_id}/instances/{instance_id}/real-time-session
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
project_id |
Yes |
Definition Project ID of a tenant in a region. To obtain the value, see Obtaining a Project ID. Constraints N/A Range The value can contain 32 characters. Only letters and digits are allowed. Default Value N/A |
|
instance_id |
Yes |
Definition Instance ID, which uniquely identifies an instance. Constraints N/A Range The value can contain 36 characters. Only letters and digits are allowed. Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. You can obtain the token by calling the IAM API used to obtain a user token. After the request is processed, the value of X-Subject-Token in the message header is the token value. Constraints N/A Range N/A Default Value N/A |
|
X-Language |
No |
String |
Definition Language. Constraints N/A Range
Default Value en-us |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
node_id |
Yes |
String |
Definition Node ID. Constraints This API is suitable only for nodes with CNs or DNs (primary or standby DNs). Range N/A Default Value N/A |
|
component_id |
Yes |
String |
Definition Component ID. Constraints Only the ID of a CN or DN (primary or standby) component deployed on the node specified by node_id is allowed. Range N/A Default Value N/A |
|
query_info |
No |
Object |
Definition Filter criteria used to obtain real-time sessions. For details, see Table 4. Constraints N/A |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
database_name |
No |
String |
Definition Database name. Constraints N/A Range N/A Default Value N/A |
|
client_ip |
No |
String |
Definition IP address of the client. Constraints N/A Range N/A Default Value N/A |
|
user_name |
No |
String |
Definition Username. Constraints N/A Range N/A Default Value N/A |
Response Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
sessions |
Array of objects |
Definition Real-time sessions of the DB instance. For details, see Table 6. |
|
Parameter |
Type |
Description |
|---|---|---|
|
session_id |
String |
Definition Session ID. Range N/A |
|
pid |
String |
Definition Thread ID. Range N/A |
|
unique_sql_id |
String |
Definition SQL ID. Range N/A |
|
database_name |
String |
Definition Database. Range N/A |
|
client_ip |
String |
Definition IP address of the client. Range N/A |
|
user_name |
String |
Definition Username. Range N/A |
|
wait |
String |
Definition Whether to wait. Range N/A |
|
block_session |
String |
Definition Blocked session ID. Range N/A |
|
wait_event |
String |
Definition Wait event. Range N/A |
|
state |
String |
Definition Status. Range N/A |
|
query_runtime |
String |
Definition Statement execution duration. Range N/A |
|
query |
String |
Definition SQL text. Range N/A |
|
back_end_start |
Long |
Definition Start time of the session. Range N/A |
|
transaction_start |
Long |
Definition Transaction start time. Range N/A |
|
query_start |
Long |
Definition Start time of the statement. Range N/A |
|
application_name |
String |
Definition Application name. Range N/A |
|
exec_time |
String |
Definition Session duration, in seconds. Range N/A |
|
trans_num |
String |
Definition Number of transactions. Range N/A |
|
rollback_num |
String |
Definition Number of rollbacks. Range N/A |
|
sql_num |
String |
Definition Number of SQL statements. Range N/A |
|
client_port |
String |
Definition TCP port number that the client uses for communication with the backend (–1 if a Unix socket is used). Range N/A |
|
query_id |
String |
Definition Query statement ID. Range N/A |
|
transaction_time_cost |
String |
Definition Duration of the last transaction executed by the current user. Range N/A |
|
trace_id |
String |
Definition Trace ID specified by the driver, which is used to identify a request of an application. Range N/A |
|
global_session_id |
String |
Definition ID of the last global session executed by the current user. Range N/A |
|
top_transaction_id |
String |
Definition ID of the last top-level transaction executed by the current user. Range N/A |
|
current_transaction_id |
String |
Definition ID of the last transaction executed by the current user. Range N/A |
|
xlog_quantity_pretty |
String |
Definition Amount of Xlogs used by the last transaction executed by the current user, in readable format. Range N/A |
|
wait_status |
String |
Definition Waiting status of the instance thread. Range N/A |
|
lwt_id |
String |
Definition Lightweight thread ID of the instance. Range N/A |
|
thread_name |
String |
Definition Instance thread name. Range N/A |
|
lock_mode |
String |
Definition Lock wait mode of the instance. Range N/A |
|
parent_session_id |
String |
Definition Parent session ID of the instance. Range N/A |
|
smp_id |
String |
Definition Concurrent thread ID of the instance. Range N/A |
|
lock_tag |
String |
Definition Information about the lock that the instance thread is waiting to obtain. Range N/A |
|
component_name |
String |
Definition Component name. Range N/A |
Example Request
POST https://{Endpoint}/gaussdb/v3/0483b6b16e954cb88930a360d2c4e663/instances/cc6fd964d93f4003851dfc29d57d30a5in14/real-time-session
{
"node_id": "52c25e148a4a48c293b66ca95565719cno14",
"component_id": "cn_5001",
"query_info": {
"database_name": "postgres",
"client_ip": "127.0.0.1",
"user_name": "user1"
}
}
Example Response
{
"sessions" : [{
"session_id" : "725",
"pid" : "140623987341056",
"unique_sql_id" : "3545025713",
"database_name" : "postgres",
"client_ip" : "23.100.74.131",
"user_name" : "root",
"wait" : "f",
"block_session" : "",
"wait_event" : "none",
"state" : "active",
"query_runtime" : "00:00:22.641774",
"query" : "select pg_sleep(100);",
"back_end_start" : 1690448618645,
"transaction_start" : 1690448618689,
"query_start" : 1690448618689,
"application_name" : "gsql" ,
"exec_time": "97",
"trans_num": "0",
"rollback_num": "0",
"sql_num": "0",
"client_port": "60642",
"query_id": "1946117988995447961",
"transaction_time_cost": "12.2350",
"trace_id": "",
"global_session_id": "",
"top_transaction_id": "0",
"current_transaction_id": "0",
"xlog_quantity_pretty": "0 bytes",
"wait_status": "none",
"lwt_id": "124841",
"thread_name": "gsql",
"lock_mode": "",
"parent_session_id": "",
"smp_id": "0",
"lock_tag": "",
"component_name": "dn_6001"
}]
}
Status Codes
- Normal
- Abnormal
For details, see Status Codes.
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot