All Products
Search
Document Center

Database Autonomy Service:GetMySQLAllSessionAsync

Last Updated:Jun 10, 2026

Mengkueri sesi instans secara asinkron dan mengumpulkan statistik sesi berdasarkan dimensi.

Deskripsi operasi

Catatan

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.

Coba sekarang

Coba API ini di OpenAPI Explorer tanpa perlu penandatanganan manual. Panggilan yang berhasil akan secara otomatis menghasilkan contoh kode SDK sesuai dengan parameter Anda. Unduh kode tersebut dengan kredensial bawaan yang aman untuk penggunaan lokal.

Test

RAM authorization

Tabel berikut menjelaskan otorisasi yang diperlukan untuk memanggil API ini. Anda dapat menentukannya dalam kebijakan Resource Access Management (RAM). Kolom pada tabel dijelaskan sebagai berikut:

  • Action: Aksi yang dapat digunakan dalam elemen Action pada pernyataan kebijakan izin RAM untuk memberikan izin guna melakukan operasi tersebut.

  • API: API yang dapat Anda panggil untuk melakukan aksi tersebut.

  • Access level: Tingkat akses yang telah ditentukan untuk setiap API. Nilai yang valid: create, list, get, update, dan delete.

  • Resource type: Jenis resource yang mendukung otorisasi untuk melakukan aksi tersebut. Ini menunjukkan apakah aksi tersebut mendukung izin tingkat resource. Resource yang ditentukan harus kompatibel dengan aksi tersebut. Jika tidak, kebijakan tersebut tidak akan berlaku.

    • Untuk API dengan izin tingkat resource, jenis resource yang diperlukan ditandai dengan tanda bintang (*). Tentukan Nama Sumber Daya Alibaba Cloud (ARN) yang sesuai dalam elemen Resource pada kebijakan.

    • Untuk API tanpa izin tingkat resource, ditampilkan sebagai All Resources. Gunakan tanda bintang (*) dalam elemen Resource pada kebijakan.

  • Condition key: Kunci kondisi yang didefinisikan oleh layanan. Kunci ini memungkinkan kontrol granular, berlaku baik hanya untuk aksi maupun untuk aksi yang terkait dengan resource tertentu. Selain kunci kondisi spesifik layanan, Alibaba Cloud menyediakan serangkaian common condition keys yang berlaku di semua layanan yang didukung RAM.

  • Dependent action: Aksi dependen yang diperlukan untuk menjalankan aksi tersebut. Untuk menyelesaikan aksi tersebut, pengguna RAM atau role RAM harus memiliki izin untuk melakukan semua aksi dependen.

Action

Access level

Resource type

Condition key

Dependent action

hdm:GetMySQLAllSessionAsync

get

*全部资源

*

None None

Parameter permintaan

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

ID Instans.

Catatan

Hanya Instans ApsaraDB RDS for MySQL, PolarDB Basis Data Relasional Cloud-Native for MySQL, dan PolarDB Basis Data Relasional Cloud-Native-X 2.0 yang didukung.

rm-2ze8g2am97624****

NodeId

string

No

ID node.

Catatan

Anda harus menentukan parameter ini untuk klaster PolarDB Basis Data Relasional Cloud-Native for MySQL. Jika Anda tidak menentukan ID node, data Sesi node utama akan dikembalikan secara default.

pi-wz954ryd8f893****

ResultId

string

No

ID permintaan asinkron.

Catatan

GetMySQLAllSessionAsync adalah operasi asinkron. Setelah permintaan dikirim, sistem tidak mengembalikan hasil lengkap tetapi mengembalikan ID permintaan. Anda harus menggunakan ID permintaan untuk mengirim permintaan hingga bidang isFinish di tanggapan bernilai true, yang menunjukkan bahwa hasil lengkap telah dikembalikan. Untuk memperoleh data lengkap, Anda harus memanggil operasi ini setidaknya dua kali.

async__507044db6c4eadfa2dab9b084e80****

Elemen respons

Element

Type

Description

Example

object

The response parameters.

Code

integer

The HTTP status code returned.

200

Message

string

The returned message.

Catatan

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:

  • true

  • false

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.

Catatan

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.

Catatan

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.

Catatan

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.

Catatan

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

  • false

true

State

string

The state of the asynchronous request. Valid values:

  • RUNNING

  • SUCCESS

  • FAIL

SUCCESS

Complete

boolean

Indicates whether the asynchronous request was complete. Valid values:

  • true

  • false

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

  • false

true

Contoh

Respons sukses

JSONformat

{
  "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
}

Kode kesalahan

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.

Lihat Error Codes untuk daftar lengkap.

Catatan rilis

Lihat Release Notes untuk daftar lengkap.