Queries the SQL audit logs for a cluster.
Operation description
You can query SQL audit logs only if SQL Audit is enabled. You can retrieve SQL audit logs generated within the last 30 days. If you disable and then re-enable SQL Audit, you can retrieve only logs generated after SQL Audit is re-enabled. SQL audit logs do not record INSERT INTO VALUES, REPLACE INTO VALUES, or UPSERT INTO VALUES operations.
For the endpoints of this service, see Endpoints.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
adb:DescribeAuditLogRecords |
list |
*DBClusterLakeVersion
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| DBClusterId |
string |
Yes |
Cluster ID for the Enterprise Edition, Basic Edition, or Data Lakehouse Edition. Note
You can call the DescribeDBClusters operation to list all cluster IDs in the destination region. |
amv-t4nj8619bz2w3**** |
| RegionId |
string |
Yes |
The region ID. Note
Call the DescribeRegions operation to query the region ID of the cluster. |
cn-hangzhou |
| StartTime |
string |
No |
The start of the time range to query. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC. Note
You can query SQL audit logs only when SQL Audit is enabled. You can query SQL audit logs that are generated within the last 30 days. If you disable and then re-enable SQL Audit, you can query only the logs that are generated after SQL Audit is re-enabled. |
2022-08-12T04:17Z |
| EndTime |
string |
No |
The end of the time range to query. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC. Note
|
2022-08-12T17:08Z |
| DBName |
string |
No |
The name of the database on which the SQL statement was executed. |
adb_demo |
| QueryKeyword |
string |
No |
A string that is used as a keyword to search for in the results. |
adb |
| SqlType |
string |
No |
The SQL statement type. Valid values:
Note
You can query logs for only one type of SQL statement at a time. If you do not set this parameter, logs for all types of SQL statements are queried. |
SELECT |
| Succeed |
string |
No |
Indicates whether the SQL statement was successfully executed. Valid values:
|
true |
| HostAddress |
string |
No |
The IP address and port number of the client that is used to execute the SQL statement. |
100.104.XX.XX:43908 |
| OrderType |
string |
No |
The order in which to sort the retrieved entries by the execution time of the SQL statement. Valid values:
|
asc |
| User |
string |
No |
The username that is used to execute the SQL statement. |
test |
| Order |
string |
No |
The order in which to sort the retrieved entries by field. Specify the order as a JSON array of key-value pairs. Entries are sorted based on the order of the key-value pairs in the array. Each key-value pair consists of a
|
[{"Field":"ExecuteTime","Type":"Desc"},{"Field":"HostAddress","Type":"Asc"}] |
| PageSize |
integer |
No |
The number of entries to return on each page. Valid values:
|
10 |
| PageNumber |
integer |
No |
The page number. The value must be an integer that is greater than 0. The default value is 1. |
1 |
| ProxyUser |
string |
No |
A reserved parameter. |
无 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The details of the list. |
||
| TotalCount |
string |
The total number of entries. |
6974 |
| PageSize |
string |
The number of entries per page. |
10 |
| RequestId |
string |
The request ID. |
8A564B7F-8C00-43C0-8EC5-919FBB70573 |
| PageNumber |
string |
The page number. |
1 |
| DBClusterId |
string |
The ID of the Data Lakehouse Edition cluster. |
amv-t4nj8619bz2w3**** |
| Items |
array<object> |
The list of entries. |
|
|
object |
The list of SQL records. |
||
| HostAddress |
string |
The IP address and port number of the client that is used to execute the SQL statement. |
100.104.XX.XX:43908 |
| Succeed |
string |
Indicates whether the SQL statement was successfully executed. Valid values:
|
true |
| SQLText |
string |
The details of the SQL statement. |
SELECT * FROM adb_hdfs_import_source |
| TotalTime |
string |
The execution duration of the SQL statement. Unit: milliseconds (ms). |
216 |
| ConnId |
string |
The connection ID. |
14356**** |
| DBName |
string |
The name of the database on which the SQL statement was executed. |
adb_demo |
| SQLType |
string |
The type of the SQL statement. |
SELECT |
| ExecuteTime |
string |
The time when the SQL statement started to be executed. The time is in the `yyyy-MM-dd HH:mm:ss` format and is your local time. |
2022-08-12 10:10:00 |
| ExecuteTimestamp |
integer |
||
| ProcessID |
string |
The task ID. |
202106081752021720161662490345362390 |
| User |
string |
The username that is used to execute the SQL statement. |
test |
| HasDiagnosticInfo |
boolean |
Examples
Success response
JSON format
{
"TotalCount": "6974",
"PageSize": "10",
"RequestId": "8A564B7F-8C00-43C0-8EC5-919FBB70573",
"PageNumber": "1",
"DBClusterId": "amv-t4nj8619bz2w3****",
"Items": [
{
"HostAddress": "100.104.XX.XX:43908",
"Succeed": "true",
"SQLText": "SELECT * FROM adb_hdfs_import_source",
"TotalTime": "216",
"ConnId": "14356****",
"DBName": "adb_demo",
"SQLType": "SELECT",
"ExecuteTime": "2022-08-12 10:10:00",
"ExecuteTimestamp": 0,
"ProcessID": "202106081752021720161662490345362390",
"User": "test",
"HasDiagnosticInfo": false
}
]
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 404 | InvalidDBCluster.NotFound | The DBClusterId provided does not exist in our records. | The specified DBClusterId parameter does not exist. Make sure that the DBClusterId value is valid. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.