Consulta assincronamente as sessões de uma instância e coleta estatísticas das sessões com base em dimensões.
Descrição da operação
GetMySQLAllSessionAsync é uma operação assíncrona. Após o envio de uma solicitação, o sistema não retorna resultados completos, mas retorna um ID de solicitação. Você precisa usar o ID de solicitação para iniciar solicitações até que o valor do campo isFinish nos resultados retornados seja true, quando então os resultados completos serão retornados. Isso indica que, para obter dados completos, você deve chamar esta operação pelo menos duas vezes.
-
Esta operação é aplicável apenas a instâncias do ApsaraDB RDS for MySQL, clusters do PolarDB for MySQL e instâncias do PolarDB-X 2.0.
-
Se você usar um SDK do Alibaba Cloud ou um SDK do Database Autonomy Service (DAS) para chamar esta operação, recomendamos que use a versão mais recente do SDK.
-
Se você usar um SDK para chamar operações do DAS, deverá definir o ID da região como cn-shanghai.
Experimente agora
Testar
Autorização RAM
|
Ação |
Nível de acesso |
Tipo de recurso |
Chave de condição |
Ação dependente |
|
hdm:GetMySQLAllSessionAsync |
get |
*All Resource
|
Nenhuma | Nenhuma |
Parâmetros da solicitação
|
Parâmetro |
Tipo |
Obrigatório |
Descrição |
Exemplo |
| InstanceId |
string |
Sim |
O ID da instância. Nota
Há suporte apenas para instâncias do ApsaraDB RDS for MySQL, PolarDB for MySQL e PolarDB-X 2.0. |
rm-2ze8g2am97624**** |
| NodeId |
string |
Não |
O ID do nó. Nota
Você deve especificar este parâmetro para clusters do PolarDB for MySQL. Se você não especificar um ID de nó, os dados de sessão do nó primário serão retornados por padrão. |
pi-wz954ryd8f893**** |
| ResultId |
string |
Não |
O ID da solicitação assíncrona. Nota
GetMySQLAllSessionAsync é uma operação assíncrona. Após o envio de uma solicitação, o sistema não retorna resultados completos, mas retorna um ID de solicitação. Você precisa usar o ID de solicitação para iniciar solicitações até que o valor do campo isFinish nos resultados retornados seja true, quando então os resultados completos serão retornados. Isso indica que, para obter dados completos, você deve chamar esta operação pelo menos duas vezes. |
async__507044db6c4eadfa2dab9b084e80**** |
Elementos de resposta
|
Elemento |
Tipo |
Descrição |
Exemplo |
|
object |
Os parâmetros de resposta. |
||
| Code |
integer |
O código de status HTTP retornado. |
200 |
| Message |
string |
A mensagem retornada. Nota
Se a solicitação for bem-sucedida, Successful será retornado. Se a solicitação falhar, uma mensagem de erro, como um código de erro, será retornada. |
Successful |
| Data |
object |
Os dados retornados. |
|
| Fail |
boolean |
Indica se a solicitação assíncrona falhou. Valores válidos:
|
false |
| SessionData |
object |
Os dados da sessão. |
|
| 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. Nota
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. Nota
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. Nota
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. Nota
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 |
O ID da solicitação assíncrona. |
async__507044db6c4eadfa2dab9b084e80**** |
| IsFinish |
boolean |
Indica se a solicitação assíncrona foi concluída. Valores válidos:
|
true |
| State |
string |
O estado da solicitação assíncrona. Valores válidos:
|
SUCCESS |
| Complete |
boolean |
Indica se a solicitação assíncrona foi concluída. Valores válidos:
|
true |
| Timestamp |
integer |
A hora em que a solicitação assíncrona foi feita. Este valor é um carimbo de data/hora UNIX que representa o número de milissegundos decorridos desde 1º de janeiro de 1970, 00:00:00 UTC. |
1660100753556 |
| RequestId |
string |
O ID da solicitação. |
B6D17591-B48B-4D31-9CD6-9B9796B2**** |
| Success |
boolean |
Indica se a solicitação foi bem-sucedida. Valores válidos:
|
true |
Exemplos
Resposta de sucesso
JSON formato
{
"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
}
Códigos de erro
|
Código de status HTTP |
Código de erro |
Mensagem de erro |
Descrição |
|---|---|---|---|
| 400 | InvalidParams | The request parameters are invalid. | |
| 403 | NoPermission | You are not authorized to do this action. |
Consulte Códigos de Erro para uma lista completa.
Notas de versão
Consulte Notas de Versão para uma lista completa.