All Products
Search
Document Center

AnalyticDB:DescribeSparkAuditLogRecords

Last Updated:Nov 10, 2025

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.

Note You can query only SQL audit logs that are executed by using Spark Interactive Resource Group.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

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 Resources is 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.
OperationAccess levelResource typeCondition keyAssociated operation
adb:DescribeSparkAuditLogRecordslist
*DBClusterLakeVersion
acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBClusterIdstringYes

The cluster ID.

Note
amv-bp1j7******78j8i
RegionIdstringYes

The region ID.

Note You can call the DescribeRegions operation to query the available regions and zones, including region ID.
cn-shanghai
StartTimestringYes

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
EndTimestringYes

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
UserstringNo

The username that is used to execute SQL statements.

test_user
OrderstringNo

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 and Type. For example:[{"Field":"CreateTime", "Type": "desc" }]. Where:

  • Field specifies the field that is used to sort the SQL statements. Valid values:

    • ResourceGroupName: The name of the resource group.
    • Status :SQL execution status.
    • User: The username that is used to execute the SQL statement.
    • ExecuteTime: The start time of SQL execution.
    • TotalTime: The amount of time consumed to execute the SQL statement.
    • ProcessId: Query ID.
    • ClientIp: The source IP address.
    • StatementSource: The source from which the query was initiated.
  • Type specifies the sorting order. Valid values (case-insensitive):

    • Desc: Descending order.
    • Asc: Ascending order.
[{\"Field\":\"ExecuteTime\",\"Type\":\"Desc\"}]
PageSizeintegerNo

The number of entries to return on each page.

30
PageNumberintegerNo

The page number.

1
ProxyUserstringNo

This parameter is deprecated.

user
ResourceGroupNamestringNo

The resource group name.

Note You can call the DescribeDBResourceGroup operation to query the resource group ID within a cluster.
test_job
StatusstringNo

The execution status of the SQL statement.

Valid values:

  • cancel: The task is canceled .
  • finished: The execution succeeds .
  • error:The execution fails .
  • timeout: The execution timed out .
finish
StatementIdstringNo

The ID of the statement.

fbd22066-1c03-xxxx-aa16-6ae28288****
TotalTimestringNo

The duration of the SQL statement. Unit: milliseconds.

3000
SQLTextstringNo

The keyword in the SQL statement.

test_table_name
ProcessIdstringNo

The query ID.

999f2439-6b10-xxxx-a5d3-daf3b35c****
ClientIpstringNo

The source IP address.

192.168.XX.XX
StatementSourcestringNo

The source from which the query was initiated.

Valid values:

  • SQL_EDITOR: SQL_EDITOR.
  • JDBC: JDBC.
SQL_EDITOR

Response parameters

ParameterTypeDescriptionExample
object
TotalCountstring

The total number of entries.

100
PageSizestring

The number of entries to return per page.

30
RequestIdstring

The request ID.

2D5867CF-423F-559F-BBB1-199A289E****
PageNumberstring

The page number.

1
DBClusterIdstring

The cluster ID.

amv-bp1j7******78j8i
Itemsarray<object>

The list of SQL audit logs.

itemsobject

Details.

SQLTextstring

The SQL statement.

SELECT * FROM adb_hdfs_import_source
TotalTimelong

The duration of the SQL statement. Unit: milliseconds.

40000
ExecuteTimestring

The start time of the SQL statement. The time is in the yyyy-MM-ddTHH:mm:ssZ format. The time is in UTC.

2022-01-23T16:05:08Z
Userstring

The username that is used to execute SQL statements.

test_user
StatementIdstring

The ID of the statement.

fbd22066-1c03-xxxx-aa16-6ae28288****
Statusstring

The execution status of the SQL statement.

Valid values:

  • cancel: The task is canceled .
  • finished: The execution succeeds .
  • error: The execution fails .
  • timeout: The execution of the command timed out.
finish
ResourceGroupNamestring

The resource group name.

test_job
AppIdstring

The Spark application ID.

s202411061011hzc5d6476000****
InnerQueryIdstring

The ID of the query executed within the Spark application.

1
IsDiagnosableboolean

Whether it can be diagnosed.

true
ClientIpstring

The source IP address.

192.168.XX.XX
ProcessIdstring

The query ID.

999f2439-6b10-xxxx-a5d3-daf3b35c****
StatementSourcestring

The source from which the query was initiated.

Valid values:

  • SQL_EDITOR: SQL_EDITOR.
  • JDBC: JDBC.
SQL_EDITOR
ErrorMsgstring

The SQL execution error message.

notFoundIp
ErrorTracestring

The SQL execution error stack trace.

notFoundIpException
AccessDeniedDetailstring

The details about the access denial. This parameter is returned only if Resource Access Management (RAM) permission verification failed.

{ "PolicyType": "AccountLevelIdentityBasedPolicy", "AuthPrincipalOwnerId": "1*****************7", "EncodedDiagnosticMessage": "AQIBIAAAAOPdwKY2QLOvgMEc7SkkoJfj1kvZwsaRqNYMh10Tv0wTe0fCzaCdrvgazfNb0EnJKETgXyhR+3BIQjx9WAqZryejBsp1Bl4qI5En/D9dEhcXAtKCxCmE2kZCiEzpy8BoEUt+bs0DmlaGWO5xkEpttypLIB4rUhDvZd+zwPg4EXk4KSSWSWsurxtqDkKEMshKlQFBTKvJcKwyhk62IeYly4hQ+5IpXjkh1GQXuDRCQ==", "AuthPrincipalType": "SubUser", "AuthPrincipalDisplayName": "2***************9", "NoPermissionType": "ImplicitDeny", "AuthAction": "adb:DescribeExcessivePrimaryKeys" }

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 codeError codeError messageDescription
404InvalidDBCluster.NotFoundThe 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.