Querying Historical Sessions
Function
This API is used to query historical sessions.
- Before calling this API, learn how to authenticate it.
- Before calling this API, learn about the request header parameters.
Authorization Information
- If you are using role/policy-based authorization, see Permissions and Supported Actions for details on the required permissions.
- If you are using identity policy-based authorization, the following identity policy-based permissions are required.
| Action | Access Level | Resource Type (*: required) | Condition Key | Alias | Dependencies |
|---|---|---|---|---|---|
| rds:instance:getHistorySession | list | - | g:EnterpriseProjectId g:ResourceTag/<tag-key> | - | - |
Constraints
This API is available only for RDS for PostgreSQL.
URI
- URI format
GET /v3/{project_id}/instances/{instance_id}/history-session?start_time={start_time}&end_time={end_time}
- Parameter description
Table 1 Parameters 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
N/A
Default Value
N/A
instance_id
Yes
Definition
Instance ID.
You can obtain the value of this parameter from id in Table 4 by calling the API for querying DB instances.
Constraints
N/A
Range
N/A
Default Value
N/A
pid
No
Definition
Process ID.
Constraints
N/A
Range
N/A
Default Value
N/A
user_name
No
Definition
Username.
Constraints
N/A
Range
N/A
Default Value
N/A
database_name
No
Definition
Database name.
Constraints
N/A
Range
N/A
Default Value
N/A
start_time
Yes
Definition
Start time.
Constraints
The value is in the UTC timestamp format.
Range
N/A
Default Value
N/A
end_time
Yes
Definition
End time.
Constraints
The value is in the UTC timestamp format.
Range
N/A
Default Value
N/A
offset
No
Definition
Index offset. If offset is set to N, the query starts from the N+1 piece of data. The value 0 indicates that the query starts from the first piece of data.
Constraints
The value must be a non-negative number.
Range
An integer greater than or equal to 0
Default Value
0
limit
No
Definition
Number of records returned by a query.
Constraints
N/A
Range
[1, 1000]
Default Value
100
Request
None
Example Request
Query historical sessions.
GET https://{Endpoint}/v3/0483b6b16e954cb88930a360d2c4e663/instances/24c6678f474241fe89ee9c42f768022ein03/history-session?start_time=1764669600000&end_time=1765249000000 Response
- Normal response
Table 2 Parameters Parameter
Type
Description
total_count
Integer
Definition
Total number of records.
Range
N/A
sessions
Arrayofobjects
Definition
Session information list.
For details, see Table 3.
Table 3 sessions field description Parameter
Type
Description
sample_time
String
Definition
Sampling time.
Range
N/A
blocked_process_id
String
Definition
Blocked process ID.
Range
N/A
database_oid
Integer
Definition
Database OID.
Range
N/A
database_name
String
Definition
Database name.
Range
N/A
session_id
Integer
Definition
Session ID.
Range
N/A
parallel_leader_id
Integer
Definition
Concurrent session ID.
Range
N/A
backend_user_oid
Integer
Definition
Backend user OID.
Range
N/A
user_name
String
Definition
Username.
Range
N/A
app_name
String
Definition
Application name.
Range
N/A
client_ip_address
String
Definition
Client address.
Range
N/A
client_host_name
String
Definition
Client name.
Range
N/A
client_port
Integer
Definition
Client port.
Range
N/A
session_start_time
String
Definition
Time when the session was established.
Range
N/A
transaction_start_time
String
Definition
Time when the transaction was started.
Range
N/A
transaction_execution_time
Integer
Definition
Transaction duration (s).
Range
N/A
query_start_time
String
Definition
Query start time.
Range
N/A
state_change_time
String
Definition
State change time.
Range
N/A
wait_event_type
String
Definition
Type of the wait event.
Range
N/A
wait_event_name
String
Definition
Name of the wait event.
Range
N/A
session_status
String
Definition
Session status.
Range
N/A
backend_xid
Integer
Definition
Backend XID.
Range
N/A
backend_xmin
Integer
Definition
Backend Xmin.
Range
N/A
query_id
String
Definition
Query ID.
Range
N/A
sql_statement
String
Definition
SQL statement.
Range
N/A
process_type
String
Definition
Process type.
Range
N/A
memory_usage
Float
Definition
Memory usage (%).
Range
N/A
process_status
String
Definition
Process status.
Range
N/A
cpu_usage
Float
Definition
Average CPU usage (%) in 3s.
Range
N/A
io_wait_status
Float
Definition
I/O wait time (s).
Range
N/A
disk_read_rate
Float
Definition
Disk read rate (MB/s).
Range
N/A
disk_write_rate
Float
Definition
Disk write rate (MB/s).
Range
N/A
- Example normal response
{ "sessions" : [ { "sample_time" : "2025-12-02 18:03:27", "blocked_process_id" : "", "database_oid" : 5, "database_name" : "postgres", "session_id" : 16152, "backend_user_oid" : 16392, "user_name" : "rdsMetric", "app_name" : "", "client_port" : -1, "session_start_time" : "2025-12-01 15:57:34", "query_start_time" : "2025-12-02 18:03:24", "state_change_time" : "2025-12-02 18:03:24", "wait_event_type" : "Client", "wait_event_name" : "ClientRead", "session_status" : "idle", "query_id" : "134890507541751252", "sql_statement" : "select failed_count from pg_stat_archiver;", "process_type" : "client backend", "memory_usage" : 0.5593106, "process_status" : "sleeping", "cpu_usage" : 0, "io_wait_status" : 0, "disk_read_rate" : 0, "disk_write_rate" : 0 } ], "total_count" : 1 } - Abnormal response
For details, see Abnormal Request Results.
Status Code
- Normal
- Abnormal
For details, see Status Codes.
Error Code
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