Asynchronously queries the sessions of an instance and collects statistics on the sessions based on dimensions.
Operation description
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.
- 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.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action
policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- The required resource types are displayed in bold characters.
- If the permissions cannot be granted at the resource level,
All Resources
is used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
hdm:GetMySQLAllSessionAsync | get | *All Resources * |
| 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 parameters
Examples
Sample success responses
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 |
---|---|---|
400 | InvalidParams | The request parameters are invalid. |
403 | NoPermission | You are not authorized to do this action. |
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-08-25 | API Description Update. The Error code has changed. The response structure of the API has changed | View Change Details |