Queries the SQL audit logs of a cluster.
Operation description
SQL audit logs can be queried only when SQL audit is enabled, and only logs from the last 30 days are supported. If SQL audit is shutdown and then re-enabled, only logs generated after re-enabling can be queried. SQL audit logs do not record INSERT INTO VALUES, REPLACE INTO VALUES, or UPSERT INTO VALUES operations.
For the service registration of this service, see Service registration.
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 |
The cluster ID of the Data Lakehouse Edition cluster. Note
You can call the DescribeDBClusters operation to query the cluster IDs of all clusters in a specified region. |
amv-t4nj8619bz2w3**** |
| RegionId |
string |
Yes |
The region ID. Note
You can call the DescribeRegions operation to query the region ID of the cluster. |
cn-hangzhou |
| StartTime |
string |
No |
The beginning of the time range to query. Specify the time in UTC in the yyyy-MM-ddTHH:mmZ format. Note
SQL audit logs can be queried only when SQL audit is enabled, and only logs from the last 30 days are supported. If SQL audit is disabled and then re-enabled, only logs generated after re-enabling can be queried. |
2022-08-12T04:17Z |
| EndTime |
string |
No |
The end of the time range to query. Specify the time in UTC in the yyyy-MM-ddTHH:mmZ format. Note
|
2022-08-12T17:08Z |
| DBName |
string |
No |
The name of the database on which the SQL statement is executed. |
adb_demo |
| QueryKeyword |
string |
No |
The keyword used to search the returned results. |
adb |
| SqlType |
string |
No |
The type of the SQL statement. Valid values:
Note
Only one type can be specified per request. If this parameter is not specified, all types are queried by default. |
SELECT |
| Succeed |
string |
No |
Specifies whether the SQL statement is executed successfully. Valid values:
|
true |
| HostAddress |
string |
No |
The IP address and port number of the client that executes the SQL statement. |
100.104.XX.XX:43908 |
| OrderType |
string |
No |
The order in which the results are sorted by SQL execution time. Valid values:
|
asc |
| User |
string |
No |
The username that executes the SQL statement. |
test |
| Order |
string |
No |
The sorting order based on specified fields. The value is in JSON format and is an ordered JSON array. Compound sorting is performed in the order of the input array. The array contains the
|
[{"Field":"ExecuteTime","Type":"Desc"},{"Field":"HostAddress","Type":"Asc"}] |
| PageSize |
integer |
No |
The number of entries per page. Valid values:
|
10 |
| PageNumber |
integer |
No |
The page number. The value must be a positive integer that does not exceed the maximum value of the Integer data type. Default value: 1. |
1 |
| ProxyUser |
string |
No |
A reserved parameter. |
None |
| EngineType |
string |
No |
Valid values:
|
XIHE |
|
No |
The engine type. Valid values:
If this parameter is not specified, the default value is XIHE. Valid values:
|
XIHE |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The list details. |
||
| 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 cluster ID of the Data Lakehouse Edition cluster. |
amv-t4nj8619bz2w3**** |
| Items |
array<object> |
The list. |
|
|
object |
The SQL audit log entries. |
||
| HostAddress |
string |
The IP address and port number of the client that executes the SQL statement. |
100.104.XX.XX:43908 |
| Succeed |
string |
Indicates whether the SQL statement is executed successfully. 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 is executed. |
adb_demo |
| SQLType |
string |
The type of the SQL statement. |
SELECT |
| ExecuteTime |
string |
The execution start time of the SQL statement in local time. Format: yyyy-MM-dd HH:mm:ss. |
2022-08-12 10:10:00 |
| ExecuteTimestamp |
integer |
The execution start time of the SQL statement. The value is a UNIX timestamp in milliseconds. |
1774600396584 |
| ProcessID |
string |
The task ID. |
202106081752021720161662490345362390 |
| User |
string |
The username that executes the SQL statement. |
test |
| HasDiagnosticInfo |
boolean |
Indicates whether diagnostic information is included. Valid values:
|
true |
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": 1774600396584,
"ProcessID": "202106081752021720161662490345362390",
"User": "test",
"HasDiagnosticInfo": true
}
]
}
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.