Retrieves hot data from SQL audit logs.
Operation description
Before you call this API, ensure that you meet the following requirements:
Use the latest version of the Alibaba Cloud SDK or DAS SDK.
When using an SDK to call the DAS service, specify the region as
cn-shanghai.Supported engines: PolarDB MySQL, ApsaraDB RDS for MySQL, ApsaraDB RDS for PostgreSQL, and ApsaraDB RDS for SQLServer.
Enable log indexing for the instance.
The query start time must be within the last 7 days. The query duration cannot exceed 1 day. The API returns up to 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 | The start of the time range to query. This value must be a Unix timestamp in milliseconds. Note You can query only data that is generated after you enable DAS Enterprise Edition. The start time cannot be earlier than seven days before the current time. | 1684734297000 |
End | integer | Yes | The end of the time range to query. This value must be a Unix timestamp in milliseconds. Note The end time must be later than the start time. The time range cannot exceed one day. | 1684820697000 |
QueryKeyword | string | No | The query keyword. Note Fuzzy search is supported. You can specify up to 10 keywords. Separate multiple keywords with a space. For example: a1 b2 c3. | a1 b2 |
AccountName | string | No | The database account. Note You can specify multiple database accounts. Separate multiple accounts with a space. For example: | testuser |
DBName | string | No | The database name. Note You can specify multiple database names. Separate multiple names with a space. For example: | testDB |
HostAddress | string | No | The client IP address. Note You can specify multiple client IP addresses. Separate multiple IP addresses with a space. For example: | 47.100.XX.XX |
LogicalOperator | string | No | The logical operator to use with multiple keywords. Valid values:
| or |
MaxLatancy | integer | No | The maximum execution time in microseconds. Returns SQL statements that have an execution time less than this value. | 100 |
MaxScanRows | integer | No | The maximum number of scanned rows. Returns SQL statements that scanned fewer than this number of rows. | 10000 |
MinLatancy | integer | No | The minimum execution time in microseconds. Returns SQL statements with an execution time greater than or equal to this value. | 10 |
MinScanRows | integer | No | The minimum number of scanned rows. Returns SQL statements that scanned at least this number of rows. | 10 |
SqlType | string | No | The SQL type. Valid values:
| select |
State | string | No | The execution state. Set this parameter to 0 to query for successfully executed SQL statements. You can also specify an error code to query for the corresponding SQL statements. | 0 |
ThreadID | string | No | The thread ID. Note You can specify multiple thread IDs. Separate multiple IDs with a space. For example: | 657 |
PageNumbers | integer | No | The page number to return. Pages start from 1. The default value is 1. | 2 |
MaxRecordsPerPage | integer | No | The maximum number of entries per page. Valid values: 5 to 100. | 10 |
SortKey | string | No | The sort key. Valid values:
| ScanRows |
SortMethod | string | No | The sort order. Valid values:
| ASC |
ChildDBInstanceIDs | string | No | The node ID. Note This parameter is required if the database instance is a PolarDB for MySQL cluster. | pi-bp179lg03445l**** |
Role | string | No | A reserved parameter. | None |
TraceId | string | No | A reserved parameter. | None |
MinRows | integer | No | A reserved parameter. | None |
MaxRows | integer | No | A reserved parameter. | None |
MinSpillCnt | integer | No | A reserved parameter. | None |
MaxSpillCnt | integer | No | A reserved parameter. | None |
TransactionId | string | No | The transaction ID. | 0 |
Fail | string | No | The SQL execution error code. You can call the GetAsyncErrorRequestStatByCode operation to obtain the error code. | 1064 |
Response elements
Element | Type | Description | Example |
object | |||
Code | string | The status code. | 200 |
Message | string | The response message. Note If the request succeeds, Successful is returned. If the request fails, an error message is returned, which may include an error code. | Successful |
RequestId | string | The unique request ID generated by Alibaba Cloud. | 0A74B755-98B7-59DB-8724-1321B394**** |
Success | string | Indicates whether the request succeeded:
| true |
| Data | object | The returned data. | |
| List | array<object> | A list of the returned data. | |
object | The SQL insight and audit data. | ||
Latancy | integer | The latency, in microseconds. | 10000 |
Ext | string | A reserved parameter. | None |
ExecuteTime | string | The UTC time when the execution was recorded, formatted as | 2023-05-23 T12:11:20Z |
OriginTime | string | The precise UTC time when the execution was recorded, formatted as | 2023-05-23 T12:11:20.999Z |
HostAddress | string | The client IP address. | 47.100.XX.XX |
UpdateRows | integer | The number of updated rows. | 30 |
LogicRead | integer | The number of logical reads. | 12 |
SQLText | string | The SQL statement. | select 1 |
LockTime | integer | The lock wait time, in microseconds. | 1 |
ScanRows | integer | The number of scanned rows. | 29 |
ThreadID | integer | The thread ID. | 657 |
State | string | The execution status. A value of 0 indicates success. Any other value is an error code. | 0 |
DBName | string | The database name. | testDB |
SqlType | string | The SQL type. Valid values:
| select |
AccountName | string | The database account. | testuser |
PhysicSyncRead | integer | The number of physical synchronous reads. | 0 |
PhysicAsyncRead | integer | The number of physical asynchronous reads. | 0 |
TransactionId | string | The transaction ID. | 0 |
ReturnRows | integer | The number of returned rows. | 1 |
NodeId | string | The node ID. | pi-bp120roy76f3qbd84 |
Total | integer | The total number of records. | 20 |
PageNo | integer | The page number. | 2 |
PageSize | integer | The page size. | 10 |
Extra | any | A 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": "pi-bp120roy76f3qbd84"
}
],
"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.