Queries the session history of Session Manager.
Operation description
You can query Session Manager session records created within the last 30 days. A maximum of 1,000 successful records are retained.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ecs:DescribeTerminalSessions |
list |
*Instance
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID. |
cn-hangzhou |
| InstanceId |
string |
No |
The instance ID. |
i-bp1i7gg30r52z2em**** |
| SessionId |
string |
No |
The session ID. |
s-hz023od0x9**** |
| MaxResults |
integer |
No |
The maximum number of entries per page for a paged query. Maximum value: 100. Default value: 10. |
10 |
| NextToken |
string |
No |
The pagination token. Set this parameter to the NextToken value returned in the previous API call. |
AAAAAdDWBF2**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| NextToken |
string |
The pagination token returned in this call. |
AAAAAdDWBF2**** |
| Sessions |
object |
||
| Session |
array<object> |
The session list. |
|
|
array<object> |
The session information. |
||
| CreationTime |
string |
The time when the session was created. |
2024-01-19T09:15:46Z |
| TargetServer |
string |
The address of the service that was accessed in a virtual private cloud (VPC) from the instance. |
192.168.0.246 |
| PortNumber |
integer |
The port number of the instance, which is used for data forwarding. If no port number was specified for data forwarding when the session was created, this parameter is empty. |
22 |
| PrincipalId |
string |
The ID of the principal. Valid values based on the
|
123456xxxx |
| Username |
string |
The username used to establish connections. |
root |
| ClientIP |
string |
The IP address of the client used to establish connections. |
192.168.1.1 |
| IdentityType |
string |
The principal type. Valid values:
|
RAMUser |
| SessionId |
string |
The session ID. |
s-hz023od0x9**** |
| Connections |
object |
||
| Connection |
array<object> |
The information of the connections. |
|
|
object |
The connection. |
||
| ClosedReason |
string |
The reason why the connection was closed. This parameter is returned only when the
|
AgentNeedUpgrade |
| EndTime |
string |
The time when the connection was closed. |
2024-01-19T09:16:46Z |
| Status |
string |
The state of the session. Valid values:
|
Connecting |
| StartTime |
string |
The time when the connection started to be established. |
2024-01-19T09:16:40Z |
| InstanceId |
string |
The instance ID. |
i-bp1i7gg30r52z2em**** |
| FailedDetail |
string |
Cause of the connection failure. This parameter is returned only when the Status parameter is Failed. |
The Session Manager is closed normally. |
Examples
Success response
JSON format
{
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"NextToken": "AAAAAdDWBF2****",
"Sessions": {
"Session": [
{
"CreationTime": "2024-01-19T09:15:46Z",
"TargetServer": "192.168.0.246",
"PortNumber": 22,
"PrincipalId": "123456xxxx",
"Username": "root",
"ClientIP": "192.168.1.1",
"IdentityType": "RAMUser",
"SessionId": "s-hz023od0x9****",
"Connections": {
"Connection": [
{
"ClosedReason": "AgentNeedUpgrade",
"EndTime": "2024-01-19T09:16:46Z",
"Status": "Connecting",
"StartTime": "2024-01-19T09:16:40Z",
"InstanceId": "i-bp1i7gg30r52z2em****",
"FailedDetail": "The Session Manager is closed normally."
}
]
}
}
]
}
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter.NextToken | The specified parameter NextToken is not valid. | The specified parameter NextToken is illegal. |
| 400 | InvalidParameter.MaxResults | The specified parameter MaxResults is not valid. | The specified parameter MaxResults is illegal. |
| 500 | InternalError | An error occurred when you dispatched the request. | An error occurred while sending the request, please try again later. |
| 403 | Operation.Forbidden | The operation is not permitted. | The operation is not supported. |
| 404 | InvalidRegionId.NotFound | The specified parameter RegionId does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.