Queries the SQL audit logs for a Spark Interactive resource group.
Operation description
SQL audit logs can be queried only when SQL audit is enabled. Only SQL audit logs within the last 30 days can be queried. If SQL auditing is turned off midway, when it is re-enabled, you can only query the SQL audit logs generated after it was turned back on.
Debugging
Authorization information
The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:
- Operation: the value that you can use in the Action element to specify the operation on a resource.
- Access level: the access level of each operation. The levels are read, write, and list.
- Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
- For mandatory resource types, indicate with a prefix of * .
- If the permissions cannot be granted at the resource level,
All Resourcesis used in the Resource type column of the operation.
- Condition Key: the condition key that is defined by the cloud service.
- Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
| Operation | Access level | Resource type | Condition key | Associated operation |
|---|---|---|---|---|
| adb:DescribeSparkAuditLogRecords | list | *DBClusterLakeVersion acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId} |
| none |
Request parameters
| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
| DBClusterId | string | Yes | amv-bp1j7******78j8i | |
| RegionId | string | Yes | The region ID. Note
You can call the DescribeRegions operation to query the available regions and zones, including region ID.
| cn-shanghai |
| StartTime | string | Yes | Query start time. Format: yyyy-MM-ddTHH:mmZ (UTC time). Note
We recommend that you set the query start time to any point in time within 30 days.
| 2025-09-25T00:00Z |
| EndTime | string | Yes | Query end time. The end time must be later than the start time, and the interval between them must be less than 1 day. Format: yyyy-MM-ddTHH:mmZ (UTC time). | 2025-09-25T01:00Z |
| User | string | No | The username that is used to execute SQL statements. | test_user |
| Order | string | No | Sort the SQL statements based on specified fields. The format is a JSON array that preserves order, and composite sorting is performed according to the sequence of objects in the array. Each object contains two fields:
| [{\"Field\":\"ExecuteTime\",\"Type\":\"Desc\"}] |
| PageSize | integer | No | The number of entries to return on each page. | 30 |
| PageNumber | integer | No | The page number. | 1 |
| ProxyUser | string | No | This parameter is deprecated. | user |
| ResourceGroupName | string | No | The resource group name. Note
You can call the DescribeDBResourceGroup operation to query the resource group ID within a cluster.
| test_job |
| Status | string | No | The execution status of the SQL statement. Valid values:
| finish |
| StatementId | string | No | The ID of the statement. | fbd22066-1c03-xxxx-aa16-6ae28288**** |
| TotalTime | string | No | The duration of the SQL statement. Unit: milliseconds. | 3000 |
| SQLText | string | No | The keyword in the SQL statement. | test_table_name |
| ProcessId | string | No | The query ID. | 999f2439-6b10-xxxx-a5d3-daf3b35c**** |
| ClientIp | string | No | The source IP address. | 192.168.XX.XX |
| StatementSource | string | No | The source from which the query was initiated. Valid values:
| SQL_EDITOR |
Response parameters
Examples
Sample success responses
JSONformat
{
"TotalCount": 100,
"PageSize": 30,
"RequestId": "2D5867CF-423F-559F-BBB1-199A289E****",
"PageNumber": 1,
"DBClusterId": "amv-bp1j7******78j8i",
"Items": [
{
"SQLText": "SELECT * FROM adb_hdfs_import_source",
"TotalTime": 40000,
"ExecuteTime": "2022-01-23T16:05:08Z",
"User": "test_user",
"StatementId": "fbd22066-1c03-xxxx-aa16-6ae28288****",
"Status": "finish",
"ResourceGroupName": "test_job",
"AppId": "s202411061011hzc5d6476000****",
"InnerQueryId": 1,
"IsDiagnosable": true,
"ClientIp": "192.168.XX.XX",
"ProcessId": "999f2439-6b10-xxxx-a5d3-daf3b35c****",
"StatementSource": "SQL_EDITOR",
"ErrorMsg": "notFoundIp",
"ErrorTrace": "notFoundIpException"
}
],
"AccessDeniedDetail": {
"PolicyType": "AccountLevelIdentityBasedPolicy",
"AuthPrincipalOwnerId": "1*****************7",
"EncodedDiagnosticMessage": "AQIBIAAAAOPdwKY2QLOvgMEc7SkkoJfj1kvZwsaRqNYMh10Tv0wTe0fCzaCdrvgazfNb0EnJKETgXyhR+3BIQjx9WAqZryejBsp1Bl4qI5En/D9dEhcXAtKCxCmE2kZCiEzpy8BoEUt+bs0DmlaGWO5xkEpttypLIB4rUhDvZd+zwPg4EXk4KSSWSWsurxtqDkKEMshKlQFBTKvJcKwyhk62IeYly4hQ+5IpXjkh1GQXuDRCQ==",
"AuthPrincipalType": "SubUser",
"AuthPrincipalDisplayName": "2***************9",
"NoPermissionType": "ImplicitDeny",
"AuthAction": "adb:DescribeExcessivePrimaryKeys"
}
}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. |
For a list of error codes, visit the Service error codes.
