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.
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
Test
RAM authorization
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: | testuser |
DBName | string | No | Database name. Note Supports combining multiple database names for queries, with database names separated by spaces. For example: | testDB |
HostAddress | string | No | Client IP address. Note Supports combining multiple client IP addresses for queries, with IP addresses separated by spaces. For example: | 47.100.XX.XX |
LogicalOperator | string | No | Logical relationship between multiple keywords.
| 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 |
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: | 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.
| SCAN_ROWS |
SortMethod | string | No | Sorting method.
| 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
| Successful |
RequestId | string | The unique request ID. | 0A74B755-98B7-59DB-8724-1321B394**** |
Success | string | Indicates whether the request was successful:
| 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: | 2023-05-23 T12:11:20Z |
OriginTime | string | Execution time in UTC format: | 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 |
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.