All Products
Search
Document Center

AnalyticDB:DescribeDiagnosisRecords

Last Updated:Aug 28, 2026

Retrieves diagnostic records for SQL statements that match specified conditions in an AnalyticDB for MySQL cluster.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

adb:DescribeDiagnosisRecords

get

DBCluster

acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}

None None

Request parameters

Parameter

Type

Required

Description

Example

DBClusterId

string

Yes

The cluster ID.

Note

You can call the DescribeDBClusters operation to query the information about all AnalyticDB for MySQL clusters within a region, including cluster IDs.

am-bp1r053byu48p****

StartTime

string

Yes

The start of the query time range, as a UNIX timestamp in milliseconds.

Note

Only data within the last 14 days can be queried.

1632931200000

EndTime

string

Yes

The end of the query time range, as a UNIX timestamp in milliseconds.

Note
  • The end time must be later than the start time.

  • The maximum time range that can be specified is 24 hours.

1633017540000

RegionId

string

Yes

The region ID of the cluster.

Note

You can call the DescribeRegions operation to query the most recent region list.

cn-hangzhou

QueryCondition

string

Yes

The filter condition for SQL statements, which can contain the Type, Value, and Min or Max fields. Specify the condition in JSON format. Type specifies the query dimension. Valid values for Type: maxCost, status, and cost. Value, Min, or Max specifies the query range for the dimension. Valid values:

  • {"Type":"maxCost","Value":"100"}: queries the top 100 most time-consuming SQL statements. Set Value to 100.

  • {"Type":"status","Value":"finished"}: queries executed SQL statements. You can set Value to running to query SQL statements that are being executed. You can also set Value to failed to query SQL statements that failed to be executed.

  • {"Type":"cost","Min":"10","Max":"200"}: queries SQL statements whose execution durations are in the range of 10 to 200 milliseconds. You can also customize the maximum and minimum execution durations.

{"Type":"status","Value":"finished"}

Keyword

string

No

The keyword to filter SQL statements.

select

MinPeakMemory

integer

No

The minimum peak memory of the SQL statements. Unit: bytes.

0

MaxPeakMemory

integer

No

The maximum peak memory of the SQL statements. Unit: bytes.

89000000

MinScanSize

integer

No

The minimum scan size of the SQL statements. Unit: bytes.

0

MaxScanSize

integer

No

The maximum scan size of the SQL statements. Unit: bytes.

104428198

ResourceGroup

string

No

The resource group to which the SQL statements belong.

Note

You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address of the SQL statements to be queried.

user_default

UserName

string

No

The username that executed the SQL statements.

Note

You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address of the SQL statements to be queried.

test_user

Database

string

No

The database on which the SQL statements are executed.

Note

You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address of the SQL statements to be queried.

adb_demo

ClientIp

string

No

The source IP address.

Note

You can call the DescribeDiagnosisDimensions operation to query the resource group, database name, username, and source IP address of the SQL statements to be queried.

59.82.xx.xx

Order

string

No

The sort order for the retrieved SQL statements. Specify this value in JSON format. The value is an ordered array that contains the Field and Type fields. Example: [{"Field":"StartTime", "Type": "desc" }]. Fields:

  • Field specifies the field that is used to sort the retrieved SQL statements. Valid values:

    • StartTime: the start time of the execution.

    • Status: the execution state.

    • UserName: the username.

    • Cost: the execution duration.

    • PeakMemory: the peak memory.

    • ScanSize: the amount of data to be scanned.

    • Database: the name of the database.

    • ClientIp: the source IP address.

    • ResourceGroup: the name of the resource group.

    • QueueTime: the queuing duration.

    • OutputRows: the number of output rows.

    • OutputDataSize: the size of output data.

    • ResourceCostRank: the execution duration rank of operators that are used in the SQL statements. This field takes effect only when QueryCondition is set to {"Type":"status","Value":"running"}.

  • Type specifies the sorting order. Valid values (case-insensitive):

    • Desc: descending order.

    • Asc: ascending order.

[{"Field":"StartTime", "Type": "desc" }]

PageNumber

integer

No

The page number. Pages start from page 1. Default value: 1.

1

PageSize

integer

No

The number of entries per page. Valid values: 30, 50, and 100. Default value: 30.

30

Lang

string

No

The language of file titles and error messages. Valid values:

  • zh (default): simplified Chinese.

  • en: English.

  • ja: Japanese.

  • zh-tw: traditional Chinese.

zh

PatternId

string

No

The SQL pattern ID.

Note

You can call the DescribeSQLPatterns operation to query the information about all SQL patterns within an AnalyticDB for MySQL cluster in a time range, including SQL pattern IDs.

5575924945138******

Response elements

Element

Type

Description

Example

object

The response parameters.

PageNumber

integer

The page number.

1

PageSize

integer

The number of entries per page.

30

TotalCount

integer

The total number of entries returned.

1

Querys

array<object>

The queried SQL statements.

array<object>

The queried SQL statement.

SQL

string

The SQL statement.

Note

For performance reasons, SQL statements exceeding 5,120 characters are truncated. You can call the DownloadDiagnosisRecords operation to download the diagnostic information about SQL statements that match specified conditions in an AnalyticDB for MySQL cluster, including the complete SQL statements.

SELECT count(*)\nFROM nation

SQLTruncatedThreshold

integer

The maximum length of the SQL statement. The value 5120 is returned. Unit: characters. Statements exceeding this limit are truncated.

5120

Status

string

The state of the SQL statement. Valid values:

  • running

  • finished

  • failed

finished

OutputDataSize

integer

The size of returned data. Unit: bytes.

9

Cost

integer

The total execution duration. Unit: milliseconds.

Note

This value is the cumulative value of the QueuedTime, TotalPlanningTime, and ExecutionTime parameters.

10

OutputRows

integer

The number of rows returned.

1

RcHost

string

The IP address and port number of the AnalyticDB for MySQL frontend node that executed the SQL statement.

10.0.xx.xx:3004

ScanSize

integer

The amount of scanned data. Unit: bytes.

9

ProcessId

string

The query ID.

2021093000414401000000023503151******

StartTime

integer

The execution start time of the SQL statement, as a UNIX timestamp in milliseconds.

1632933704000

SQLTruncated

boolean

Indicates whether the SQL statement is truncated. Valid values:

  • true

  • false

false

Database

string

The name of the database on which the SQL statement is executed.

adb_demo

ScanRows

integer

The number of entries scanned.

1

ResourceCostRank

integer

The execution duration rank of operators used in the SQL statement.

Note

This field is returned only for SQL statements that have the Status parameter set to running.

1

ClientIp

string

The source IP address.

59.82.xx.xx

PeakMemory

integer

The peak memory. Unit: bytes.

16648

QueueTime

integer

The queuing duration. Unit: milliseconds.

0

ResourceGroup

string

The resource group to which the SQL statement belongs.

user_default

UserName

string

The username that executed the SQL statement.

test_user

ExecutionTime

integer

The execution duration. Unit: milliseconds.

6

TotalPlanningTime

integer

The time spent generating the execution plan. Unit: milliseconds.

4

EtlWriteRows

integer

The number of rows written by an extract-transform-load (ETL) task.

0

TotalStages

integer

The total number of stages generated.

2

QueryProperties

array<object>

The query properties.

object

The query property.

Name

string

The name of the query property.

ff

Value

string

The value of the query property.

40

PatternId

string

The SQL pattern ID.

Note

You can call the DescribePatternPerformance operation to query the performance metrics of an SQL pattern within a time range.

-5575924945138******

RequestId

string

The request ID.

109462AF-B5FA-3D5A-9377-B27E5B******

Examples

Success response

JSON format

{
  "PageNumber": 1,
  "PageSize": 30,
  "TotalCount": 1,
  "Querys": [
    {
      "SQL": "SELECT count(*)\\nFROM nation",
      "SQLTruncatedThreshold": 5120,
      "Status": "finished",
      "OutputDataSize": 9,
      "Cost": 10,
      "OutputRows": 1,
      "RcHost": "10.0.xx.xx:3004",
      "ScanSize": 9,
      "ProcessId": "2021093000414401000000023503151******",
      "StartTime": 1632933704000,
      "SQLTruncated": false,
      "Database": "adb_demo",
      "ScanRows": 1,
      "ResourceCostRank": 1,
      "ClientIp": "59.82.xx.xx",
      "PeakMemory": 16648,
      "QueueTime": 0,
      "ResourceGroup": "user_default",
      "UserName": "test_user",
      "ExecutionTime": 6,
      "TotalPlanningTime": 4,
      "EtlWriteRows": 0,
      "TotalStages": 2,
      "QueryProperties": [
        {
          "Name": "ff",
          "Value": "40"
        }
      ],
      "PatternId": "-5575924945138******"
    }
  ],
  "RequestId": "109462AF-B5FA-3D5A-9377-B27E5B******"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.