All Products
Search
Document Center

:DescribeAuditLogRecords

Last Updated:Aug 30, 2024

Queries the SQL audit logs of an AnalyticDB for MySQL cluster.

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 audit was disabled and re-enabled, only SQL audit logs from the time when SQL audit was re-enabled can be queried. The following operations are not recorded in SQL audit logs: INSERT INTO VALUES, REPLACE INTO VALUES, and UPSERT INTO VALUES.
  • For information about the endpoints of AnalyticDB for MySQL, see Endpoints .

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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:
    • The required resource types are displayed in bold characters.
    • 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:DescribeAuditLogRecordslist
  • All Resources
    *
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBClusterIdstringYes

The ID of the AnalyticDB for MySQL Data Lakehouse Edition (V3.0) cluster.

Note You can call the DescribeDBClusters operation to query the IDs of all AnalyticDB for MySQL Data Lakehouse Edition (V3.0) clusters within a region.
amv-t4nj8619bz2w3****
RegionIdstringYes

The region ID of the cluster.

Note You can call the DescribeRegions operation to query the most recent region list.
cn-hangzhou
StartTimestringYes

The beginning of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Note 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 audit was disabled and re-enabled, only SQL audit logs from the time when SQL audit was re-enabled can be queried.
2022-08-12T04:17Z
EndTimestringYes

The end of the time range to query. Specify the time in the ISO 8601 standard in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

Note
  • The end time must be later than the start time.

  • The maximum time range that can be specified is 24 hours.

2022-08-12T17:08Z
DBNamestringNo

The name of the database on which the SQL statement was executed.

adb_demo
QueryKeywordstringNo

The keyword based on which audit logs are queried. You can set this parameter to a value of the STRING type.

adb
SqlTypestringNo

The type of the SQL statement. Valid values:

  • DELETE
  • SELECT
  • UPDATE
  • INSERT INTO SELECT
  • ALTER
  • DROP
  • CREATE
Note You can query only a single type of SQL statements at a time. If you leave this parameter empty, the SELECT statements are queried.
SELECT
SucceedstringNo

Specifies whether the execution of the SQL statement succeeds. Valid values:

  • true
  • false
true
HostAddressstringNo

The IP address and port number of the client that is used to execute the SQL statement.

100.104.XX.XX:43908
OrderTypestringNo

The sorting order of the retrieved entries. Valid values:

  • asc: sorts the retrieved entries by time in ascending order.
  • desc: sorts the retrieved entries by time in descending order.
asc
UserstringNo

The username that is used to execute the SQL statement.

test
OrderstringNo

The order in which to sort the retrieved entries by field. Specify this parameter in the JSON format. The value is an ordered array that uses the order of the input array and contains Field and Type. Example: [{"Field":"ExecutionStartTime","Type":"Desc"},{"Field":"ScanRows","Type":"Asc"}]. Fields:

  • Field: the field that is used to sort the retrieved entries. Valid values:

    • HostAddress: the IP address of the client that is used to connect to the database.
    • UserName: the username.
    • ExecutionStartTime: the start time of the query execution.
    • QueryTime: the amount of time consumed to execute the SQL statement.
    • PeakMemoryUsage: the maximum memory usage when the SQL statement is executed.
    • ScanRows: the number of rows to be scanned from a data source in the task.
    • ScanSize: the amount of data to be scanned.
    • ScanTime: the total amount of time consumed to scan data.
    • PlanningTime: the amount of time consumed to generate execution plans.
    • WallTime: the accumulated CPU Time values of all operators in the query on each node.
    • ProcessID: the process ID.
  • Type: the sorting type of the retrieved entries. Valid values:

    • Desc: descending order.
    • Asc: ascending order.
[{"Field":"ExecuteTime","Type":"Desc"},{"Field":"HostAddress","Type":"Asc"}]
PageSizeintegerNo

The number of entries per page. Valid values:

  • 10 (default)
  • 30
  • 50
  • 100
10
PageNumberintegerNo

The page number. Pages start from page 1. Default value: 1.

1
ProxyUserstringNo

A reserved parameter.

none

Response parameters

ParameterTypeDescriptionExample
object

The response parameters.

TotalCountstring

The total number of entries returned.

6974
PageSizestring

The number of entries per page.

10
RequestIdstring

The request ID.

8A564B7F-8C00-43C0-8EC5-919FBB70573
PageNumberstring

The page number.

1
DBClusterIdstring

The ID of the AnalyticDB for MySQL Data Lakehouse Edition (V3.0) cluster.

amv-t4nj8619bz2w3****
Itemsarray<object>

The queried SQL audit logs.

object

The queried SQL audit log.

HostAddressstring

The IP address and port number of the client that is used to execute the SQL statement.

100.104.XX.XX:43908
Succeedstring

Indicates whether the SQL statement was successfully executed. Valid values:

  • true
  • false
true
SQLTextstring

The SQL statement.

SELECT * FROM adb_hdfs_import_source
TotalTimestring

The amount of time that is consumed to execute the SQL statement. Unit: milliseconds.

216
ConnIdstring

The connection ID.

14356****
DBNamestring

The name of the database on which the SQL statement was executed.

adb_demo
SQLTypestring

The type of the SQL statement.

SELECT
ExecuteTimestring

The start time of the execution of the SQL statement. The time is displayed in the ISO 8601 standard in the yyyy-MM-dd HH:mm:ss format. The time must be in UTC.

2022-08-12 10:10:00
ProcessIDstring

The task ID.

202106081752021720161662490345362390
Userstring

The username that is used to execute the SQL statement.

test

Examples

Sample success responses

JSONformat

{
  "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",
      "ProcessID": "202106081752021720161662490345362390",
      "User": "test"
    }
  ]
}

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.

Change history

Change timeSummary of changesOperation
2023-12-08The Error code has changedView Change Details