Queries the audit logs of SQL statements that are executed in Data Management (DMS).
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 |
---|---|---|---|---|
dms:ListSQLExecAuditLog | list | *All Resources * |
| none |
Request parameters
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
StartTime | string | Yes | The beginning of the time range to query. Note
The start time supports fuzzy match. Specify the time in the YYYY-MM-DD hh:mm:ss format.
| 2021-11-08 11:04:00 |
EndTime | string | Yes | The end of the time range to query. Note
The end time supports fuzzy match. Specify the time in the YYYY-MM-DD hh:mm:ss format. We recommend that you use the StartTime and EndTime parameters to specify a time range that does not exceed one day. The returned entries can be displayed by page to improve query efficiency.
| 2021-11-08 11:00:00 |
SearchName | string | No | The name of the database or instance based on which you want to query SQL statements. Note
If the SQL statements to be queried are at the instance level, you can set this parameter to an instance name. If the SQL statements to be queried are at the database level, you can set this parameter to a database name.
| test_SearchName |
OpUserName | string | No | The nickname of the user who wrote the SQL statement. | test_OpUserName |
SqlType | string | No | The type of the SQL statement. Valid values:
Note
To view more types of SQL statements, log on to the DMS console and click Security and Specifications. In the left-side navigation pane, click Operation Audit. Then, you can view all supported types of SQL statements from the SQL type drop-down list.
| SELECT |
ExecState | string | No | The execution status of the SQL statement. Valid values:
| SUCCESS |
PageSize | integer | Yes | The number of entries to return on each page. The value cannot exceed 100. | 20 |
PageNumber | integer | Yes | The number of the page to return. | 1 |
Tid | long | No | The ID of the tenant. You can call the GetUserActiveTenant operation to obtain the tenant ID. | 3*** |
Response parameters
Examples
Sample success responses
JSON
format
{
"TotalCount": 1,
"RequestId": "39BC9C86-95AE-58F2-9862-A7C3D896****",
"ErrorCode": "MissingStartTime",
"ErrorMessage": "StartTime is mandatory for this action.",
"Success": true,
"SQLExecAuditLogList": {
"SQLExecAuditLog": [
{
"OpTime": "2021-11-08 11:04:27",
"UserName": "test_UserName",
"UserId": 0,
"InstanceName": "polar123@pc-bp1h9tgq4st9g****.mysql.polardb.rds.aliyuncs.com:3306[polar_qw_test]",
"InstanceId": 0,
"SchemaName": "polar123",
"DbId": 0,
"Logic": false,
"SQLType": "SELECT",
"SQL": "SELECT * FROM `polar123`.`p_qw` ORDER BY `id` DESC",
"ExecState": "SUCCESS",
"AffectRows": 2,
"ElapsedTime": 18,
"Remark": "success"
}
]
}
}
Error codes
For a list of error codes, visit the Service error codes.
Change history
Change time | Summary of changes | Operation |
---|---|---|
2023-03-23 | The internal configuration of the API is changed, but the call is not affected | View Change Details |