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
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.
Operation | Access level | Resource type | Condition key | Associated operation |
---|---|---|---|---|
adb:DescribeAuditLogRecords | list |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
DBClusterId | string | Yes | 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**** |
RegionId | string | Yes | The region ID of the cluster. Note
You can call the DescribeRegions operation to query the most recent region list.
| cn-hangzhou |
StartTime | string | Yes | 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 |
EndTime | string | Yes | 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
| 2022-08-12T17:08Z |
DBName | string | No | The name of the database on which the SQL statement was executed. | adb_demo |
QueryKeyword | string | No | The keyword based on which audit logs are queried. You can set this parameter to a value of the STRING type. | adb |
SqlType | string | No | The type of the SQL statement. Valid values:
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 |
Succeed | string | No | Specifies whether the execution of the SQL statement succeeds. 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 sorting order of the retrieved entries. 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 this parameter in the JSON format. The value is an ordered array that uses the order of the input array and contains
| [{"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. Pages start from page 1. Default value: 1. | 1 |
ProxyUser | string | No | A reserved parameter. | none |
Response parameters
Examples
Sample success responses
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",
"ProcessID": "202106081752021720161662490345362390",
"User": "test"
}
]
}
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.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-12-08 | The Error code has changed | View Change Details |