All Products
Search
Document Center

Database Autonomy Service:GetDasSQLLogHotData

最終更新日:Jul 23, 2025

Retrieves hot data from SQL audit logs, allowing for fast, interactive analysis of recent SQL activity.

Operation description

Before you call this operation, ensure that the following requirements are met:

  • Supported engine: PolarDB MySQL, ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, and ApsaraDB RDS for SQLServer.

  • SDK version: Use the latest version of the Alibaba Cloud SDK.

  • Region: If you call the API via the SDK, set the region ID to cn-shanghai.

  • Log indexing must be enabled for the target instance.

Note

The query start time cannot be earlier than 7 days in the past, and the duration between the query start time and query end time cannot exceed 1 day. This API returns a maximum of 10,000 records.

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 support 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

hdm:GetDasSQLLogHotData

get

*All Resource

*

None

None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the database instance.

rm-2ze1jdv45i7l6****

Start

integer

Yes

Query start time in UNIX timestamp format, in milliseconds.

Note

You can query only the data generated after DAS Enterprise Edition is enabled. The query start time cannot be earlier than 7 days from the current time.

1684734297000

End

integer

Yes

Query end time in UNIX timestamp format, in milliseconds.

Note

The query end time must be later than the query start time, and the duration between the query start time and query end time cannot exceed 1 day.

1684820697000

QueryKeyword

string

No

Query keywords.

Note

Supports fuzzy query. You can combine up to 10 keywords for a query, with keywords separated by spaces. For example: a1 b2 c3.

test

AccountName

string

No

Database account.

Note

Supports combining multiple database accounts for queries, with accounts separated by spaces. For example: user1 user2 user3.

testuser

DBName

string

No

Database name.

Note

Supports combining multiple database names for queries, with database names separated by spaces. For example: DB1 DB2 DB3.

testDB

HostAddress

string

No

Client IP address.

Note

Supports combining multiple client IP addresses for queries, with IP addresses separated by spaces. For example: IP1 IP2 IP3.

47.100.XX.XX

LogicalOperator

string

No

Logical relationship between multiple keywords.

  • or: OR.

  • and: AND.

or

MaxLatancy

integer

No

Maximum execution time in microseconds. Queries SQL statements with execution times less than this parameter value.

100

MaxScanRows

integer

No

Maximum number of scanned rows. Queries SQL statements with scanned rows less than this parameter value.

10000

MinLatancy

integer

No

Minimum execution time in microseconds. Queries SQL statements with execution times greater than or equal to this parameter value.

10

MinScanRows

integer

No

Minimum number of scanned rows. Queries SQL statements with scanned rows greater than or equal to this parameter value.

10

SqlType

string

No

SQL statement type. Valid values:

  • select

  • update

  • delete

SELECT

State

string

No

Execution result. 0 means to query successfully executed SQL statements. You can also specify an error code to query corresponding SQL statements.

0

ThreadID

string

No

Thread ID.

Note

Supports combining multiple thread IDs for queries, with thread IDs separated by spaces. For example: Thread ID1 Thread ID2 Thread ID3.

657

PageNumbers

integer

No

Page number for paged query, starting from 1. Default value: 1.

2

MaxRecordsPerPage

integer

No

Maximum number of records per page for paged query. Valid values: 5 to 100.

10

SortKey

string

No

Sorting basis.

  • ScanRows: Number of scanned rows.

  • UpdateRows: Number of updated rows.

  • Consume: Execution time.

  • OriginTime: Execution time.

  • ReturnRows: Number of returned rows.

SCAN_ROWS

SortMethod

string

No

Sorting method.

  • ASC: Ascending order.

  • DESC: Descending order.

ase

ChildDBInstanceIDs

string

No

Node ID.

Note

Required for PolarDB MySQL instances.

pi-bp179lg03445l****

Role

string

No

Reserved parameter, not currently supported.

None

TraceId

string

No

Reserved parameter, not currently supported.

None

MinRows

integer

No

Reserved parameter, not currently supported.

None

MaxRows

integer

No

Reserved parameter, not currently supported.

None

MinSpillCnt

integer

No

Reserved parameter, not currently supported.

None

MaxSpillCnt

integer

No

Reserved parameter, not currently supported.

None

TransactionId

string

No

Transaction ID.

0

Fail

string

No

SQL execution error code. You can call GetAsyncErrorRequestStatByCode to get the error code.

1064

Response parameters

Parameter

Type

Description

Example

object

Code

string

The status code.

200

Message

string

The response message.

Note
  • When the request is successful, this parameter returns Successful.

  • When the request fails, it returns exception information (such as error codes).

Successful

RequestId

string

The unique request ID.

0A74B755-98B7-59DB-8724-1321B394****

Success

string

Indicates whether the request was successful:

  • true: The request was successful.

  • false: The request failed.

true

Data

object

The returned data.

List

array

The returned information list.

object

The returned SQL insight and audit data.

Latancy

integer

Execution time in microseconds.

10000

Ext

string

Extended information field, reserved parameter.

None

ExecuteTime

string

Execution time in UTC format: yyyy-MM-ddTHH:mm:ssZ.

2023-05-23 T12:11:20Z

OriginTime

string

Execution time in UTC format: yyyy-MM-ddTHH:mm:ss.SSSZ.

2023-05-23 T12:11:20.999Z

HostAddress

string

Client IP address.

47.100.XX.XX

UpdateRows

integer

Number of updated rows.

30

LogicRead

integer

Logical read.

12

SQLText

string

SQL statement details.

select 1

LockTime

integer

Lock wait time in microseconds.

1

ScanRows

integer

Number of scanned rows.

29

ThreadID

integer

Thread ID.

657

State

string

Status. Returns 0 for successful execution, otherwise returns an error code.

0

DBName

string

Database name.

testDB

SqlType

string

SQL type. Valid values:

  • select

  • update

  • delete

SELECT

AccountName

string

Database account.

testuser

PhysicSyncRead

integer

Physical synchronous read.

0

PhysicAsyncRead

integer

Physical asynchronous read.

0

TransactionId

string

Initiated transaction ID.

0

ReturnRows

integer

Number of returned rows.

1

NodeId

string

Total

integer

Total number of returned records.

20

PageNo

integer

Page number.

2

PageSize

integer

Number of entries per page.

10

Extra

any

Reserved parameter.

None

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "Successful",
  "RequestId": "0A74B755-98B7-59DB-8724-1321B394****",
  "Success": "true",
  "Data": {
    "List": [
      {
        "Latancy": 10000,
        "Ext": "None",
        "ExecuteTime": "2023-05-23 T12:11:20Z",
        "OriginTime": "2023-05-23 T12:11:20.999Z",
        "HostAddress": "47.100.XX.XX",
        "UpdateRows": 30,
        "LogicRead": 12,
        "SQLText": "select 1",
        "LockTime": 1,
        "ScanRows": 29,
        "ThreadID": 657,
        "State": "0",
        "DBName": "testDB",
        "SqlType": "SELECT",
        "AccountName": "testuser",
        "PhysicSyncRead": 0,
        "PhysicAsyncRead": 0,
        "TransactionId": "0",
        "ReturnRows": 1,
        "NodeId": ""
      }
    ],
    "Total": 20,
    "PageNo": 2,
    "PageSize": 10,
    "Extra": "None"
  }
}

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.