You can call the DescribeSQLLogFiles operation to query the audit log files that are generated by the SQL Explorer and Audit feature for an ApsaraDB RDS instance.
Before you call this operation, make sure that the instance runs one of the following database engines:
- MySQL
- SQL Server 2008 R2
- PostgreSQL
Debugging
Request parameters
| Parameter | Type | Required | Example | Description |
|---|---|---|---|---|
| Action | String | Yes | DescribeSQLLogFiles |
The operation that you want to perform. Set the value to DescribeSQLLogFiles. |
| DBInstanceId | String | Yes | rm-uf6wjk5xxxxxx |
The ID of the instance. |
| FileName | String | No | custinsxxxxx.csv |
The name of the audit log file. |
| PageSize | Integer | No | 30 |
The number of entries to return on each page. Valid value: 30 to 200. Default value: 30. |
| PageNumber | Integer | No | 1 |
The number of the page to return. Valid values: 1 to 100000. Default value: 1. |
Response parameters
| Parameter | Type | Example | Description |
|---|---|---|---|
| RequestId | String | 1AD222E9-E606-4A42-BF6D-8A4442913CEF |
The ID of the request. |
| PageNumber | Integer | 1 |
The page number of the returned page. |
| PageRecordCount | Integer | 10 |
The number of entries returned on the current page. |
| TotalRecordCount | Integer | 10 |
The total number of returned entries. |
| Items | Array of LogFile |
An array that consists of the returned audit log files. |
|
| LogFile | |||
| FileID | String | custinsxxxxx.csv |
The name of the audit log file. |
| LogStartTime | String | 2015-05-23T07:00:00Z |
The time at which the first SQL statement recorded in the audit log file was executed. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC. |
| LogSize | String | 3000 |
The size of the audit log file. Unit: bytes. |
| LogDownloadURL | String | http://rdslog-hz-v3.oss-cn-hangzhou.aliyuncs.com/xxxxx |
The download URL of the audit log file. If the audit log file cannot be downloaded, this parameter is null. |
| LogEndTime | String | 2015-05-24T07:00:00Z |
The time at which the last SQL statement recorded in the audit log file was executed. The time follows the ISO 8601 standard in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC. |
| LogStatus | String | Success |
The status of the audit log file. Valid values:
|
Examples
Sample requests
http(s)://rds.aliyuncs.com/?Action=DescribeSQLLogFiles
&DBInstanceId=rm-uf6wjk5xxxxxx
&<Common request parameters>
Sample success responses
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<?xml version="1.0" encoding="UTF-8" ?>
<DescribeSQLLogFilesResponse>
<items>
<FileID>ZUBaS964T3OYtxxxxxxxx</FileID>
<LogStatus>Success</LogStatus>
<LogStartTime>2015-05-23T07:00:00Z</LogStartTime>
<LogEndTime>2015-05-23T07:00:00Z</LogEndTime>
<LogDownloadURL>xxxxxx.cn-hangzhou.oss.aliyun-inc.com/xxxxx</LogDownloadURL>
<LogSize>257</LogSize>
</items>
<pageRecordCount>1</pageRecordCount>
<requestId> 1AD222E9-E606-4A42-BF6D-8A4442913CEF</requestId>
<totalRecordCount>1</totalRecordCount>
</DescribeSQLLogFilesResponse>
JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"items" : [ {
"FileID" : "ZUBaS964T3OYtxxxxxxxx",
"LogStatus" : "Success",
"LogStartTime" : "2015-05-23T07:00:00Z",
"LogEndTime" : "2015-05-23T07:00:00Z",
"LogDownloadURL" : "xxxxxx.cn-hangzhou.oss.aliyun-inc.com/xxxxx",
"LogSize" : "257"
} ],
"pageRecordCount" : 1,
"requestId" : " 1AD222E9-E606-4A42-BF6D-8A4442913CEF",
"totalRecordCount" : 1
}
Error codes
For a list of error codes, visit the API Error Center.