Asynchronously queries the sessions of an instance and collects statistics on the sessions based on dimensions.
Operation description
GetMySQLAllSessionAsync is an asynchronous operation. After a request is sent, the system does not return complete results but returns a request ID. You need to use the request ID to initiate requests until the value of the isFinish field in the returned results is true, the complete results are returned. This indicates that to obtain complete data, you must call this operation at least twice.
This operation is applicable only to ApsaraDB RDS for MySQL instances, PolarDB for MySQL clusters, and PolarDB-X 2.0 instances.
If you use an Alibaba Cloud SDK or Database Autonomy Service (DAS) SDK to call this operation, we recommend that you use the latest version of the SDK.
If you use an SDK to call operations of DAS, you must set the region ID to cn-shanghai.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
hdm:GetMySQLAllSessionAsync |
get |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| InstanceId |
string |
Yes |
The instance ID. Note
Only ApsaraDB RDS for MySQL, PolarDB for MySQL, and PolarDB-X 2.0 instances are supported. |
rm-2ze8g2am97624**** |
| NodeId |
string |
No |
The node ID. Note
You must specify this parameter for PolarDB for MySQL clusters. If you do not specify a node ID, the session data of the primary node is returned by default. |
pi-wz954ryd8f893**** |
| ResultId |
string |
No |
The asynchronous request ID. Note
GetMySQLAllSessionAsync is an asynchronous operation. After a request is sent, the system does not return complete results but returns a request ID. You need to use the request ID to initiate requests until the value of the isFinish field in the returned results is true, the complete results are returned. This indicates that to obtain complete data, you must call this operation at least twice. |
async__507044db6c4eadfa2dab9b084e80**** |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| Code |
integer |
The HTTP status code returned. |
200 |
| Message |
string |
The returned message. Note
If the request was successful, Successful is returned. If the request failed, an error message such as an error code is returned. |
Successful |
| Data |
object |
The data returned. |
|
| Fail |
boolean |
Indicates whether the asynchronous request failed. Valid values:
|
false |
| SessionData |
object |
The session data. |
|
| TotalSessionCount |
integer |
The total number of sessions. |
988 |
| ActiveSessionCount |
integer |
The total number of active sessions. |
10 |
| MaxActiveTime |
integer |
The maximum execution duration of an active session. Unit: seconds. |
6 |
| SessionList |
array<object> |
The sessions. |
|
|
object |
|||
| SessionId |
integer |
The session ID. |
14521783 |
| User |
string |
The username of the database account. |
testUser |
| Client |
string |
The IP address of the client. |
47.100.XX.XX |
| DbName |
string |
The database name. |
dbTest |
| Command |
string |
The type of the command executed in the session. |
Query |
| Time |
integer |
The execution duration of the session. Unit: seconds. |
6 |
| State |
string |
The status of the session. |
starting |
| SqlText |
string |
The SQL statement executed in the session. |
INSERT INTO ... |
| UserClientAlias |
string |
The alias of the IP address of the client. |
master-shanghai |
| TrxId |
string |
The ID of the transaction to which the session belongs. |
754300775132 |
| TrxDuration |
integer |
The duration of the transaction. Unit: seconds. |
6 |
| SqlTemplateId |
string |
The SQL template ID. Note
This parameter is returned only when you use a PolarDB-X 2.0 instance. |
a7cac1a9 |
| UserStats |
array<object> |
The sessions that are counted by database account. |
|
|
object |
|||
| Key |
string |
The database account. |
testUser |
| TotalCount |
integer |
The total number of sessions within the account. |
2 |
| ActiveCount |
integer |
The number of active sessions within the account. Note
If the type of the command executed in the session is Query or Execute and the session in the transaction is not terminated, the session is active. |
1 |
| ThreadIdList |
array |
The IDs of the sessions within the account. |
|
|
integer |
The session IDs. |
[14525727,14526269] |
|
| UserList |
array |
The database accounts to which the sessions belong. |
|
|
string |
The database account. |
['testUser'] |
|
| ClientStats |
array<object> |
The sessions that are counted by client IP address. |
|
|
object |
|||
| Key |
string |
The IP address of the client. |
47.100.XX.XX |
| TotalCount |
integer |
The total number of sessions that belong to the client IP address. |
2 |
| ActiveCount |
integer |
The number of active sessions that belong to the client IP address. Note
If the type of the command executed in the session is Query or Execute and the session in the transaction is not terminated, the session is active. |
1 |
| ThreadIdList |
array |
The IDs of the sessions that belong to the client IP address. |
|
|
integer |
The session IDs. |
[14526018,14525956] |
|
| UserList |
array |
The database accounts to which the sessions belong. |
|
|
string |
The database account. |
['testUser'] |
|
| DbStats |
array<object> |
The sessions that are counted by database. |
|
|
object |
|||
| Key |
string |
The database name. |
dbTest |
| TotalCount |
integer |
The total number of sessions of the database. |
2 |
| ActiveCount |
integer |
The number of active sessions of the database. Note
If the type of the command executed in the session is Query or Execute and the session in the transaction is not terminated, the session is active. |
1 |
| ThreadIdList |
array |
The IDs of the sessions of the database. |
|
|
integer |
The session IDs. |
[14525727,14526269] |
|
| UserList |
array |
The database accounts to which the sessions belong. |
|
|
string |
The database account. |
['testUser'] |
|
| TimeStamp |
integer |
The time when the session was queried. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC. |
1659581514000020 |
| ResultId |
string |
The ID of the asynchronous request. |
async__507044db6c4eadfa2dab9b084e80**** |
| IsFinish |
boolean |
Indicates whether the asynchronous request was complete. Valid values:
|
true |
| State |
string |
The state of the asynchronous request. Valid values:
|
SUCCESS |
| Complete |
boolean |
Indicates whether the asynchronous request was complete. Valid values:
|
true |
| Timestamp |
integer |
The time when the asynchronous request was made. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC. |
1660100753556 |
| RequestId |
string |
The request ID. |
B6D17591-B48B-4D31-9CD6-9B9796B2**** |
| Success |
boolean |
Indicates whether the request was successful. Valid values:
|
true |
Examples
Success response
JSON format
{
"Code": 200,
"Message": "Successful",
"Data": {
"Fail": false,
"SessionData": {
"TotalSessionCount": 988,
"ActiveSessionCount": 10,
"MaxActiveTime": 6,
"SessionList": [
{
"SessionId": 14521783,
"User": "testUser",
"Client": "47.100.XX.XX",
"DbName": "dbTest",
"Command": "Query",
"Time": 6,
"State": "starting",
"SqlText": "INSERT INTO ...",
"UserClientAlias": "master-shanghai",
"TrxId": "754300775132",
"TrxDuration": 6,
"SqlTemplateId": "a7cac1a9"
}
],
"UserStats": [
{
"Key": "testUser",
"TotalCount": 2,
"ActiveCount": 1,
"ThreadIdList": [
0
],
"UserList": [
"['testUser']"
]
}
],
"ClientStats": [
{
"Key": "47.100.XX.XX",
"TotalCount": 2,
"ActiveCount": 1,
"ThreadIdList": [
0
],
"UserList": [
"['testUser']"
]
}
],
"DbStats": [
{
"Key": "dbTest",
"TotalCount": 2,
"ActiveCount": 1,
"ThreadIdList": [
0
],
"UserList": [
"['testUser']"
]
}
],
"TimeStamp": 1659581514000020
},
"ResultId": "async__507044db6c4eadfa2dab9b084e80****",
"IsFinish": true,
"State": "SUCCESS",
"Complete": true,
"Timestamp": 1660100753556
},
"RequestId": "B6D17591-B48B-4D31-9CD6-9B9796B2****",
"Success": true
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParams | The request parameters are invalid. | |
| 403 | NoPermission | You are not authorized to do this action. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.