All Products
Search
Document Center

Tair:DescribeAuditRecords

Last Updated:Mar 20, 2023

Queries the audit logs of an ApsaraDB for Redis instance.

Operation Description

This operation can be called up to 100 times per minute. For more information about how to query the audit log in the ApsaraDB for Redis console, see Query the audit log.

Before you call this operation, make sure that the following requirements are met:

  • ApsaraDB for Redis instances of Community Edition or performance-enhanced instances of Enterprise Edition are used.
  • The engine version of the instance is Redis 4.0 or later.

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 keyAssociation operation
kvstore:DescribeAuditRecordsREAD
  • Redis
    acs:kvstore:{#regionId}:{#accountId}:instance/{#instanceId}
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
InstanceIdstringYes

The ID of the ApsaraDB for Redis instance for which you want to query the audit log.

r-bp1zxszhcgatnx****
NodeIdstringNo

The ID of the node on the instance. You can set this parameter to query the information about a specified node.

Note
  • This parameter is available for only read/write splitting or cluster instances of ApsaraDB for Redis.
  • You can call the DescribeLogicInstanceTopology operation to query node IDs.
  • r-bp1zxszhcgatnx****-db-0
    AccountNamestringNo

    The name of the account. By default, all accounts are queried.

    demo
    DatabaseNamestringNo

    The name of the database.

    0
    QueryKeywordsstringNo

    The keyword based on which the audit log is queried. You can pass a command as a keyword to query log data for the specified command. By default, all commands are queried.

    NoteYou can specify only one keyword in each call.
    maxclients
    HostAddressstringNo

    The IP address of the client. By default, all client IP addresses are queried.

    127.0.0.1
    PageSizeintegerNo

    The maximum number of log entries to return per page.

    30
    PageNumberintegerNo

    The page number of the page to return.

    1
    StartTimestringYes

    The start of the time range that is specified to query the audit log. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

    2019-03-24T12:10:00Z
    EndTimestringYes

    The end of the time range that is specified to query the audit log. The end time must be later than the start time. Specify the time in the yyyy-MM-ddTHH:mm:ssZ format. The time must be in UTC.

    NoteWe recommend that you set a time range of 10 minutes or less because the audit log contains a great number of entries. Do not specify a time range that is longer than one day.
    2019-03-25T12:10:00Z

    Response parameters

    ParameterTypeDescriptionExample
    object
    EndTimestring

    The end of the time range that is specified to query the audit log.

    2019-03-25T12:10:00Z
    StartTimestring

    The start of the time range that is specified to query the audit log.

    2019-03-24T12:10:00Z
    RequestIdstring

    The ID of the request.

    9F5EB478-824E-4AC4-8D2B-58F31A02****
    InstanceNamestring

    The name of the ApsaraDB for Redis instance.

    r-bp1zxszhcgatnx****
    TotalRecordCountinteger

    The total number of log entries returned.

    22222
    PageNumberinteger

    The page number of the page returned.

    1
    PageSizeinteger

    The maximum number of log entries returned on each page.

    30
    Itemsarray

    The collection of returned audit log entries.

    object
    HostAddressstring

    The client IP address.

    127.0.0.1
    SQLTextstring

    The command that was run.

    CONFIG GET maxmemory
    DatabaseNamestring

    The name of the database.

    demo
    SQLTypestring

    The type of command.

    non_read_write
    ExecuteTimestring

    The time when the command was run.

    2019-03-25T03:22:08Z
    TotalExecutionTimesstring

    The amount of time that is consumed to run the command.

    0
    NodeIdstring

    The ID of the node.

    NoteA specific node ID is returned only if a cluster or read/write splitting instance is used.
    r-bp1zxszhcgatnx****-db-0
    AccountNamestring

    The name of the account.

    demo
    IPAddressstring

    The IP address.

    192.16.100.***

    Examples

    Sample success responses

    JSONformat

    {
      "EndTime": "2019-03-25T12:10:00Z",
      "StartTime": "2019-03-24T12:10:00Z",
      "RequestId": "9F5EB478-824E-4AC4-8D2B-58F31A02****",
      "InstanceName": "r-bp1zxszhcgatnx****",
      "TotalRecordCount": 22222,
      "PageNumber": 1,
      "PageSize": 30,
      "Items": {
        "SQL": [
          {
            "HostAddress": "127.0.0.1",
            "SQLText": "CONFIG GET maxmemory",
            "DatabaseName": "demo",
            "SQLType": "non_read_write",
            "ExecuteTime": "2019-03-25T03:22:08Z",
            "TotalExecutionTimes": "0",
            "NodeId": "r-bp1zxszhcgatnx****-db-0",
            "AccountName": "demo",
            "IPAddress": "192.16.100.***"
          }
        ]
      }
    }

    Error codes

    HTTP status codeError codeError messageDescription
    400IncorrectDBInstance.NotSupportedThis instance do not support log audit.-
    400InvalidEndTime.Invalidpecified end time is before this service active time.-
    400InvalidStartTime.MalformedThe Specified parameter StartTime is not valid.-
    400InvalidEndTime.MalformedThe Specified parameter EndTime is not valid.The end time is invalid. Specify the time in the yyyy-MM-ddTHH:mmZ format. The time must be in UTC. Example: 2011-06-11T16:00Z.
    400InvalidPageSize.MalformedThe specified parameter PageSize is not valid.-
    400InvalidPageNumbers.MalformedSpecified page number is not valid.-
    400InvalidQueryTime.FormatSpecified query time is not valid.-

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