Queries the SQL audit logs of an AnalyticDB for MySQL cluster.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes DescribeAuditLogRecords

The operation that you want to perform. Set the value to DescribeAuditLogRecords.

DBClusterId String Yes am-****************

The ID of the cluster.

Note You can call the DescribeDBClusters operation to query details about all AnalyticDB for MySQL clusters in a specific region, including cluster IDs.
RegionId String Yes cn-hangzhou

The region ID of the cluster.

Note You can call the DescribeRegions operation to query the regions and zones supported by AnalyticDB for MySQL, including the region IDs.
StartTime String Yes 2021-06-08T09:53Z

The beginning of the time range to query. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

EndTime String Yes 2021-06-08T09:54Z

The end of the time range to query. The end time must be later than the start time. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC.

DBName String No adb_demo

The name of the database on which you want to execute the SQL statement.

QueryKeyword String No adb

The keywords that are included in the SQL statements to query.

SqlType String No SELECT

The type of the SQL statement. Valid values:

  • DELETE
  • SELECT
  • UPDATE
  • INSERT_INTO_SELECT
Note You can query only one type of SQL statements at a time. If this parameter is left empty, the SELECT SQL statements are queried.
Succeed String No true

The execution result of the SQL statement that you want to query. Valid values:

  • true: The SQL statement was successfully executed.
  • false: The SQL statement could not be executed.
HostAddress String No 100.104.***.***:7072

The IP address and port number of the client that is used to execute the SQL statement. Specify the value of this parameter in the IP address:port number format.

OrderType String No asc

The sorting sequence of the retrieved entries. Valid values:

  • asc: The retrieved entries are sorted by time in ascending order.
  • desc: The retrieved entries are sorted by time in descending order.
User String No test_user

The name of the user that executes the SQL statement.

PageSize Integer No 10

The number of entries to return on each page. Valid values: 10, 30, 50, and 100. Default value: 10.

PageNumber Integer No 1

The number of the page to return. The value must be an integer that is greater that 0. Default value: 1.

Response parameters

Parameter Type Example Description
TotalCount String 1

The total number of entries returned.

PageSize String 10

The number of entries returned on the current page.

RequestId String 8A564B7F-8C00-43C0-8EC5-919FBB******

The ID of the request.

PageNumber String 1

The number of pages returned.

DBClusterId String am-****************

The ID of the cluster.

Items Array of SlowLogRecord

Details about the SQL audit logs.

HostAddress String 100.104.***.***:7072

The IP address and port number of the client that is used to execute the SQL statement.

Succeed String true

Indicates whether the SQL statement was successfully executed.

SQLText String SELECT * FROM tb_courses

Details about the SQL statement.

TotalTime String 216

The time consumed to execute the SQL statement. Unit: milliseconds.

ConnId String 61918

The connection ID.

DBName String adb_test

The name of the database on which the SQL statement is executed.

SQLType String SELECT

The type of the SQL statement.

ExecuteTime String 2021-06-08 17:52:02.163

The beginning of the time range in which the SQL statement is executed. The time follows the ISO 8601 standard in the yyyy-MM-ddThh:mm:ssZ format. The time is displayed in UTC.

ProcessID String 2021060817520217201616624903453******

The ID of the task.

Examples

Sample requests

http(s)://adb.aliyuncs.com/?Action=DescribeAuditLogRecords
&DBClusterId=am-****************
&RegionId=cn-hangzhou
&StartTime=2021-06-08T09:53Z
&EndTime=2021-06-08T09:54Z
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<DescribeAuditLogRecordsResponse>
    <TotalCount>1</TotalCount>
    <RequestId>8A564B7F-8C00-43C0-8EC5-919FBB******</RequestId>
    <PageSize>10</PageSize>
    <PageNumber>1</PageNumber>
    <DBClusterId>am-****************</DBClusterId>
    <Items>
        <ConnId>61918</ConnId>
        <ExecuteTime>2021-06-08 17:52:02.163</ExecuteTime>
        <TotalTime>216</TotalTime>
        <DBName>adb_test</DBName>
        <ProcessID>2021060817520217201616624903453******</ProcessID>
        <HostAddress>100.104.***.***:7072</HostAddress>
        <SQLType>SELECT</SQLType>
        <SQLText>SELECT * FROM tb_courses</SQLText>
        <Succeed>true</Succeed>
    </Items>
</DescribeAuditLogRecordsResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "TotalCount" : 1,
  "RequestId" : "8A564B7F-8C00-43C0-8EC5-919FBB******",
  "PageSize" : 10,
  "PageNumber" : 1,
  "DBClusterId" : "am-****************",
  "Items" : [ {
    "ConnId" : "61918",
    "ExecuteTime" : "2021-06-08 17:52:02.163",
    "TotalTime" : "216",
    "DBName" : "adb_test",
    "ProcessID" : "2021060817520217201616624903453******",
    "HostAddress" : "100.104.***.***:7072",
    "SQLType" : "SELECT",
    "SQLText" : "SELECT * FROM tb_courses",
    "Succeed" : "true"
  } ]
}

Error codes

HTTP status code Error code Error message Description
404 InvalidDBCluster.NotFound The DBClusterId provided does not exist in our records. The error message returned because the specified cluster ID does not exist. Check whether the cluster ID is valid.

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