You can call this operation to query the SQL audit logs of an RDS instance.

This operation is applicable to the following database engine versions:

  • MySQL 5.5
  • MySQL 5.6
  • MySQL 5.7 High-availability Edition (based on local SSDs)
  • SQL Server 2008 R2
  • PostgreSQL
  • PPAS


You can use OpenAPI Explorer to perform debugging.

OpenAPI Explorer provides various functions to simplify API usage. For example, you can retrieve APIs, call APIs, and generate SDK sample code.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeSQLLogRecords

The operation that you want to perform. Set this parameter to DescribeSQLLogRecords.

DBInstanceId String Yes rm-uf6wjk5xxxxxxx

The ID of the instance.

StartTime String Yes 2011-06-01T15:00:00Z

The start time of the query. Format: yyyy-MM-ddTHH:mm:ssZ.

EndTime String Yes 2011-06-11T15:00:00Z

The end time of the query. It must be later than the start time. The time span between the start time and the end time must be less than 31 days. Format: yyyy-MM-ddTHH:mm:ssZ.

ClientToken String No ETnLKlblzczshOTUbOCzxxxxxxx

The client token that is used to guarantee the idempotency of requests. The client token is generated by the client and is unique among different requests. It is a string of up to 64 ASCII characters.

SQLId Long No 25623548

The unique ID of the SQL statement.

QueryKeywords String No rds

The keywords used for query. Separate multiple keywords with spaces. Up to 10 keywords can be entered in a single request.

Database String No Database

The name of the database. All databases are selected by default.

User String No user

The name of the user. All users are selected by default.

Form String No Stream

Used to generate audit files or return the list of SQL records. Valid values:

  • File: Use this value to generate audit files. Only common parameters are returned, so you need to call the DescribeSQLLogFiles API operation to obtain the download link of audit files.
  • Stream: The list of SQL records is returned.

Default value: Stream.

PageSize Integer No 30

The number of records on each page. Valid values:

  • 30
  • 50
  • 100

Default value: 30.

PageNumber Integer No 1

The page number. It must be greater than 0 and cannot exceed the maximum value of the Integer data type.

Default value: 1.

AccessKeyId String No LTAIfCxxxxxxx

The AccessKey ID issued by Alibaba Cloud for users to access services.

Response parameters

Parameter Type Example Description
TotalRecordCount Long 100

The total number of records.

PageNumber Integer 1

The page number.

PageRecordCount Integer 30

The number of SQL audit logs on the current page.

Items N/A N/A

The list of SQL audit logs.

DBName String testDB

The name of the database.

AccountName String accounttest

The account used to perform operations.

HostAddress String

The IP address of the client used to connect to the database.

SQLText String update test.zxb set id=0 limit 1

The SQL statement.

TotalExecutionTimes Long 600

The total execution time. Unit: microsecond.

ReturnRowCounts Long 30

The number of returned records.

ThreadID String 1025865428

The ID of the thread.

ExecuteTime String 2011-06-11T15:00:23Z

The execution time. Format: yyyy-MM-ddTHH:mm:ssZ.

RequestId String 08A3B71B-FE08-4B03-974F-CC7EA6DB1828

The ID of the request.


Request example

&<Common request parameters>

Normal response example

XML format

			      <SQLText>update test.zxb set id=0 limit 1</SQLText>

JSON format

				"SQLText":"update test.zxb set id=0 limit 1",

Error codes

For a list of error codes, visit the API Error Center.