Queries the SQL audit logs of an AnalyticDB for MySQL Data Warehouse Edition cluster.
Operation description
Before you call the DescribeAuditLogRecords operation to query the SQL audit logs of an AnalyticDB for MySQL cluster, you must enable SQL audit for the cluster. You can call the DescribeAuditLogConfig operation to query the status of SQL audit. If SQL audit is disabled, you can call the ModifyAuditLogConfig operation to enable SQL audit.
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.
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 | get |
|
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
DBClusterId | string | Yes | The ID of the AnalyticDB for MySQL Data Warehouse Edition (V3.0) cluster. Note
You can call the DescribeDBClusters operation to query the IDs of all AnalyticDB for MySQL Data Warehouse Edition (V3.0) clusters within a region.
| am-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-01-23T02:18Z |
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-01-23T22:18Z |
DBName | string | No | The name of the database on which you want to execute the SQL statement. | adb_demo |
QueryKeyword | string | No | The keywords that are included in the SQL statement to query. | 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 name of the user who executed the SQL statement. | test_user |
Order | string | No | The order in which specified fields are sorted. Specify this parameter as an ordered JSON array that consists of the Field and Type fields.
| [{"Field":"ExecuteTime","Type":"Desc"},{"Field":"HostAddress","Type":"Asc"}] |
PageSize | integer | No | The number of entries to return on each page. Valid values:
Note
If you do not specify this parameter, the value 10 is used.
| 10 |
PageNumber | integer | No | The number of the page to return. The value is an integer that is greater than 0. Default value: 1. | 1 |
Response parameters
Examples
Sample success responses
JSON
format
{
"TotalCount": "1",
"PageSize": "10",
"RequestId": "8A564B7F-8C00-43C0-8EC5-919FBB70573",
"PageNumber": "1",
"DBClusterId": "am-t4nj8619bz2w3****",
"Items": [
{
"HostAddress": "100.104.XX.XX:43908",
"Succeed": "true",
"SQLText": "SELECT * FROM tb_courses",
"TotalTime": "216",
"ConnId": "None\n",
"DBName": "adb_test",
"SQLType": "SELECT",
"ExecuteTime": "2022-01-23 16:05:08",
"ProcessID": "202106081752021720161662490345362390",
"User": "test_user"
}
]
}
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 |
---|---|---|
2024-01-05 | The Error code has changed | View Change Details |