All Products
Search
Document Center

AnalyticDB:DescribeAuditLogRecords

更新時間:Aug 30, 2024

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

Operation description

Before you call the DescribeAuditLogRecords operation to query the SQL audit logs of an AnalyticDB for MySQL cluster, you must enable SQL audit for the cluster. You can call the DescribeAuditLogConfig operation to query the status of SQL audit. If SQL audit is disabled, you can call the ModifyAuditLogConfig operation to enable SQL audit.

SQL audit logs can be queried only when SQL audit is enabled. Only SQL audit logs within the last 30 days can be queried. If SQL audit was disabled and re-enabled, only SQL audit logs from the time when SQL audit was re-enabled can be queried. The following operations are not recorded in SQL audit logs: INSERT INTO VALUES, REPLACE INTO VALUES, and UPSERT INTO VALUES.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer.

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.
OperationAccess levelResource typeCondition keyAssociated operation
adb:DescribeAuditLogRecordsget
  • DBCluster
    acs:adb:{#regionId}:{#accountId}:dbcluster/{#DBClusterId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DBClusterIdstringYes

The ID of the AnalyticDB for MySQL Data Warehouse Edition (V3.0) cluster.

Note You can call the DescribeDBClusters operation to query the IDs of all AnalyticDB for MySQL Data Warehouse Edition (V3.0) clusters within a region.
am-t4nj8619bz2w3****
RegionIdstringYes

The region ID of the cluster.

Note You can call the DescribeRegions operation to query the most recent region list.
cn-hangzhou
StartTimestringYes

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

Note SQL audit logs can be queried only when SQL audit is enabled. Only SQL audit logs within the last 30 days can be queried. If SQL audit was disabled and re-enabled, only SQL audit logs from the time when SQL audit was re-enabled can be queried.
2022-01-23T02:18Z
EndTimestringYes

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

Note
  • The end time must be later than the start time.
  • The maximum time range that can be specified is 24 hours.
  • 2022-01-23T22:18Z
    DBNamestringNo

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

    adb_demo
    QueryKeywordstringNo

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

    adb
    SqlTypestringNo

    The type of the SQL statement. Valid values:

    • DELETE
    • SELECT
    • UPDATE
    • INSERT_INTO_SELECT
    • ALTER
    • DROP
    • CREATE
    Note You can query only a single type of SQL statements at a time. If you leave this parameter empty, the SELECT statements are queried.
    SELECT
    SucceedstringNo

    Specifies whether the execution of the SQL statement succeeds. Valid values:

    • true
    • false
    true
    HostAddressstringNo

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

    100.104.XX.XX:43908
    OrderTypestringNo

    The sorting order of the retrieved entries. Valid values:

    • asc: sorts the retrieved entries by time in ascending order.
    • desc: sorts the retrieved entries by time in descending order.
    asc
    UserstringNo

    The name of the user who executed the SQL statement.

    test_user
    OrderstringNo

    The order in which specified fields are sorted. Specify this parameter as an ordered JSON array that consists of the Field and Type fields.

    • Field specifies the field that is used to sort the retrieved entries. Valid values:

      • HostAddress: the IP address of the client that is used to connect to the database.
      • Succeed: specifies whether the SQL statement is successfully executed.
      • TotalTime: the total amount of time that is consumed to execute the SQL statement.
      • DBName: the name of the database on which the SQL statement is executed.
      • SQLType: the type of the SQL statement.
      • User: the username that is used to execute the SQL statement.
      • ExecuteTime: the time to start executing the SQL statement.
    • Type specifies the sorting order. Valid values:

      • Desc: descending order.
      • Asc: ascending order.
    [{"Field":"ExecuteTime","Type":"Desc"},{"Field":"HostAddress","Type":"Asc"}]
    PageSizeintegerNo

    The number of entries to return on each page. Valid values:

    • 10
    • 30
    • 50
    • 100
    Note If you do not specify this parameter, the value 10 is used.
    10
    PageNumberintegerNo

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

    1

    Response parameters

    ParameterTypeDescriptionExample
    object

    Details of the SQL audit logs.

    TotalCountstring

    The total number of entries returned.

    1
    PageSizestring

    The number of entries returned per page.

    10
    RequestIdstring

    The request ID.

    8A564B7F-8C00-43C0-8EC5-919FBB70573
    PageNumberstring

    The page number of the returned page.

    1
    DBClusterIdstring

    The cluster ID.

    am-t4nj8619bz2w3****
    Itemsarray<object>

    The queried SQL audit logs.

    object

    The information about the array object.

    HostAddressstring

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

    100.104.XX.XX:43908
    Succeedstring

    Indicates whether the SQL statement was successfully executed. Valid values:

    • true
    • false
    true
    SQLTextstring

    Details of the SQL statement.

    SELECT * FROM tb_courses
    TotalTimestring

    The amount of time that is consumed to execute the SQL statement. Unit: milliseconds.

    216
    ConnIdstring

    This parameter is unavailable.

    None
    DBNamestring

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

    adb_test
    SQLTypestring

    The type of the SQL statement.

    SELECT
    ExecuteTimestring

    The start time of the execution of the SQL statement. The time is displayed in the ISO 8601 standard in the yyyy-MM-dd HH:mm:ss format. The time must be in UTC.

    2022-01-23 16:05:08
    ProcessIDstring

    The task ID.

    202106081752021720161662490345362390
    Userstring

    The name of the user who executed the SQL statement.

    test_user

    Examples

    Sample success responses

    JSONformat

    {
      "TotalCount": "1",
      "PageSize": "10",
      "RequestId": "8A564B7F-8C00-43C0-8EC5-919FBB70573",
      "PageNumber": "1",
      "DBClusterId": "am-t4nj8619bz2w3****",
      "Items": [
        {
          "HostAddress": "100.104.XX.XX:43908",
          "Succeed": "true",
          "SQLText": "SELECT * FROM tb_courses",
          "TotalTime": "216",
          "ConnId": "None\n",
          "DBName": "adb_test",
          "SQLType": "SELECT",
          "ExecuteTime": "2022-01-23 16:05:08",
          "ProcessID": "202106081752021720161662490345362390",
          "User": "test_user"
        }
      ]
    }

    Error codes

    HTTP status codeError codeError messageDescription
    404InvalidDBCluster.NotFoundThe DBClusterId provided does not exist in our records.The specified DBClusterId parameter does not exist. Make sure that the DBClusterId value is valid.

    For a list of error codes, visit the Service error codes.

    Change history

    Change timeSummary of changesOperation
    2024-01-05The Error code has changedView Change Details