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 | 
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"
   }] 
 }
 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 
    