Query SQL audit logs

Last Updated: Dec 06, 2017

Description

Query the SQL audit logs generated for an instance.

Request parameters

Name Type Required? Description
Action String Yes Required parameter. Value: DescribeSQLLogRecords.
DBInstanceId String Yes Instance ID.
Database String No Default value: All.
User String No Default value: All.
Form String No File: trigger of audit log file generation. If this parameter is set to File, only public parameters are returned, and you must call DescribeSQLLogFiles interface to obtain the final download file address; if this parameter is set to Stream, data streams are returned. Default value: Stream.
QueryKeywords String No Keywords used for query, which are separated by spaces. Up to 10 keywords can be entered.
StartTime String Yes Query start time. Format: yyyy-MM-dd’T’HH:mm:ssZ.
EndTime String Yes Query end time, which must be later than the query start time. Format:yyyy-MM-dd’T’HH:mm:ssZ.
PageSize Integer No Number of records on every page. Values: 30, 50, and 100; default value: 30.
PageNumber Integer No Page number, which must be greater than 0, but must not exceed the maximum Integer value. Default value: 1.

Return parameters

Name Type Description
<Public Return Parameters> - For more information, see Public parameters.
TotalRecordCount Integer Total number of records.
PageNumber Integer Page number.
PageRecordCount Integer Number of SQL logs displayed on the current page.
Items List<SQLRecord> None.

SQLRecord parameters

Name Type Description
DBName String Name of a database.
AccountName String Name of an account.
HostAddress String Client IP address.
SQLText String SQL statement.
TotalExecutionTimes Long Time consumed, in the unit of microseconds.
ReturnRowCounts Long Number of returned records.
ExecuteTime String Execution time. Format: yyyy-MM-dd’T’HH:mm:ss Z, for example, 2011-05-30 T12:11:20Z.

Example

  • Request example

    1. https://rds.aliyuncs.com/?Action=DescribeSQLLogRecords
    2. &DBInstanceId=riauvjz6zajfiq6ba1370329449201
    3. &StartTime=2011-06-11T15:00:00Z
    4. &EndTime=2013-06-05T15:00:00Z
    5. &<Public Request Parameters>
  • Return example

    XML format:

    1. <DescribeSQLLogRecordsResponse>
    2. <RequestId>08A3B71B-FE08-4B03-974F-CC7EA6DB1828</RequestId>
    3. <TotalRecordCount>1</TotalRecordCount>
    4. <PageNumber>1</PageNumber>
    5. <PageRecordCount >1<PageRecordCount>
    6. <Items>
    7. <SQLRecord>
    8. <DBName>test</DBName>
    9. <AccountName>accounttest</AccountName>
    10. <HostAddress>192.168.0.121</HostAddress>
    11. <SQLText>update test.zxb set id=0 limit 1</SQLText>
    12. <TotalExecutionTimes >12</TotalExecutionTimes>
    13. <ReturnRowCounts>34</ReturnRowCounts>
    14. <ExecuteTime>2011-06-11T15:00:23Z</ExecuteTime>
    15. </SQLRecord>
    16. </Items>
    17. </DescribeSQLLogRecordsResponse>

    JSON format:

    1. {
    2. "PageNumber":1,
    3. "TotalRecordCounts":1,
    4. "ItemsCounts":1
    5. "SQLItems":
    6. {"SQLItem":
    7. [
    8. {
    9. "DBName":”test
    10. "AccountName":”accounttest
    11. "HostAddress":” 192.168.0.121
    12. "SQLText":”update test.zxb set id=0 limit 1
    13. "TotalExecutionTimes":12
    14. "ReturnRowCounts":34
    15. "ExecuteTime":”2011-06-11T15:00:23Z
    16. }
    17. ]
    18. },
    19. "RequestId": "08A3B71B-FE08-4B03-974F-CC7EA6DB1828"
    20. }
Thank you! We've received your feedback.