All Products
Search
Document Center

Database Autonomy Service:DescribeSqlLogRecords

Last Updated:Dec 19, 2025

You can call the DescribeSqlLogRecords operation to query the details of logs in Database Autonomy Service (DAS) Enterprise Edition.

Operation description

Before you call this operation, note the following:

  • When you use an Alibaba Cloud or Database Autonomy Service (DAS) software development kit (SDK), you must use the latest version.

  • When you use an SDK to call the DAS service, you must set the region to cn-shanghai.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

hdm:DescribeSqlLogRecords

list

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

Yes

The ID of the database instance.

pc-2ze8g2am97624****

NodeId

string

No

The node ID.

  • For ApsaraDB RDS for MySQL and PolarDB for MySQL, this parameter applies only to cluster instances. If you do not specify this parameter, the log details of the primary node are queried by default.

  • For PolarDB-X 2.0, set this parameter to polarx_cn for a compute node or polarx_dn for a data node.

pi-uf6k5f6g3912i****

Role

string

No

The role of the node in the PolarDB-X 2.0 database instance.

  • polarx_cn: compute node.

  • polarx_dn: data node.

polarx_cn

Filters

array<object>

No

A list of filter conditions.

object

No

The filter condition.

Key

string

No

The filter parameter.

Note

For more information about the supported filter parameters and their valid values, see the Additional information about request parameters section of this topic.

keyWords

Value

string

No

The value of the filter parameter.

select

StartTime

integer

No

The start time. This value is a UNIX timestamp that represents the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970.

1596177993000

EndTime

integer

No

The end time. This value is a UNIX timestamp that represents the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970.

1608888296000

PageNo

integer

No

The page number for the paged query. The value must be a positive integer. Default value: 1.

1

PageSize

integer

No

The number of entries per page. Maximum value: 100. Default value: 10.

10

The following values are supported for the Key parameter:

  • KeyWords: The keywords for the query. Separate multiple keywords with spaces.

  • LogicalOperator: The logical operator that connects keywords. Valid values: `and` and `or`.

  • AccountName: The database username. You can specify up to five usernames, separated by commas (,).

  • dbName: The name of the database. You can specify up to five database names, separated by commas (,).

  • HostAddress: The IP address of the client. You can specify up to five IP addresses, separated by commas (,).

  • MaxConsume: The maximum execution duration, in microseconds.

  • MinConsume: The minimum execution duration, in microseconds.

  • MaxScanRows: The maximum number of scanned rows.

  • MinScanRows: The minimum number of scanned rows.

  • SqlType: The SQL type. Valid values: `select`, `update`, `insert`, and `delete`.

  • State: The execution state. Valid values: `0` (successful) and `1` (failed).

  • ThreadId: The thread ID.

  • SortKey: The column by which to sort the results. Valid values: `ScanRows` (number of scanned rows), `UpdateRows` (number of updated rows), `Consume` (execution duration), `ExecuteTime` (running time), `ReturnRows` (number of returned rows), `LockTime` (lock wait time), `Frows` (number of rows pulled by a compute node of a PolarDB-X 2.0 instance), `Scnt` (number of requests sent from a compute node to a data node of a PolarDB-X 2.0 instance), `CpuTime` (CPU execution time), and `PhysicalRead` (physical reads).

  • SortMethod: The sorting method. Valid values: `DESC` (descending) and `ASC` (ascending). The default value is `DESC`.

  • TraceId: The trace ID of a PolarDB-X 2.0 instance.

  • MinRows: The minimum number of updated rows.

  • MaxRows: The maximum number of updated rows.

  • MinScnt: The minimum number of requests sent from a compute node (CN) to a data node (DN) of a PolarDB-X 2.0 instance.

  • MaxScnt: The maximum number of requests sent from a CN to a DN of a PolarDB-X 2.0 instance.

  • TrxId: The transaction ID.

  • Fail: The error code.

  • SqlId: The SQL ID.

  • JobId: The ID of the asynchronous task. You can use this ID to query the execution result of the task.

Response elements

Element

Type

Description

Example

object

Code

string

The HTTP status code returned.

200

Message

string

The returned message.

Note

If the request was successful, Successful is returned. If the request failed, an error message is returned.

Successful

RequestId

string

The request ID.

F43E7FB3-CE67-5FFD-A59C-EFD278BCD7BE

Success

string

Indicates whether the request was successful.

  • true: The request was successful.

  • false: The request failed.

true

Data

object

The returned data.

StartTime

integer

The start time. This value is a UNIX timestamp that represents the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970.

1596177993000

EndTime

integer

The end time. This value is a UNIX timestamp that represents the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970.

1608888296000

TotalRecords

integer

The total number of entries returned.

1

Items

object

The list of data.

SQLLogRecord

array<object>

The SQL log data.

object

The SQL log data.

Ext

string

The extended information. This parameter is reserved.

None

ExecuteTime

string

The execution time. The time is in UTC. The format is yyyy-MM-ddTHH:mm:ssZ.

2023-12-07T02:15:32Z

OriginTime

integer

The execution timestamp. This value is a UNIX timestamp that represents the number of milliseconds that have elapsed since 00:00:00 UTC on January 1, 1970.

1701886532000

HostAddress

string

The client IP address.

11.197.XX.XX

UpdateRows

integer

The number of updated rows.

0

LogicRead

integer

The number of logical reads.

0

SqlText

string

The SQL statement.

select resource_id as cluster_id, tpl_name \n\tfrom dbfree_alert_resource_tpl_ref\n\twhere user_id=? and type='cluster' group by resource_id, tpl_name

LockTime

integer

The lock wait time. Unit: milliseconds.

0

ScanRows

integer

The number of scanned rows.

0

ThreadId

integer

The thread ID.

None

State

string

The execution status.

  • 0: successful.

  • 1: failed.

0

DBName

string

The database name.

testdb

SqlType

string

The type of the SQL statement.

select

AccountName

string

The database account.

testname

PhysicSyncRead

integer

The number of synchronous physical reads.

0

PhysicAsyncRead

integer

The number of asynchronous physical reads.

0

TrxId

string

The transaction ID.

200000

ReturnRows

integer

The number of returned rows.

0

Consume

integer

The execution duration. Unit: microseconds.

58

Vip

string

The endpoint that is resolved from the query connection string.

100.115.XX.XX

NodeId

string

The node ID.

pi-uf6k5f6g3912i****

SqlId

string

The SQL ID.

c67649d4a7fb62c4f8c7a447c52b5b17

UseImciEngine

string

Indicates whether an In-Memory Column Index (IMCI) is used for the PolarDB for MySQL instance.

  • true: Yes.

  • false: No.

true

ParallelQueueTime

string

The degree of parallelism of the PolarDB for MySQL instance.

2

ParallelDegree

string

The wait time, in milliseconds, of a parallel query in a queue for a PolarDB for MySQL instance.

10

Scnt

integer

The number of requests from a CN to a DN of a PolarDB-X 2.0 instance.

10

Rows

integer

The total number of rows updated or returned by the compute node of the PolarDB-X 2.0 database instance.

10

Frows

integer

The number of rows pulled by the CN of a PolarDB-X 2.0 instance.

10

TraceId

string

The trace ID of a PolarDB-X 2.0 instance. This is the ID of the SQL statement that is executed on the data node.

14c93b7c7bf00000

PhysicRead

integer

The number of physical reads.

0

CpuTime

integer

The CPU execution time. Unit: microseconds.

100

Writes

integer

The number of writes for an ApsaraDB RDS for SQL Server instance.

10

Collection

string

This parameter is reserved.

None

TableName

string

Finish

string

Indicates whether the task is complete.

  • 0: The task is not complete.

  • 1: The task is complete.

Note

If the value of Finish is 0 and the JobId field is returned, the current request is an asynchronous request. The result cannot be obtained immediately. Use the value of JobId to make another query. To query the result, set Filters to [{"Key": "JobId", "Value": "******"}].

1

JobId

string

The ID of the asynchronous task.

MzI4NTZfUUlOR0RBT19DTTlfTlUyMF9NWVNRTF9PREJTX0xWU18zMjg1Nl9teXNxbF9XZWQgTWFyIDA2IDE0OjUwOjQ3IENTVCAyMDI0XzBfMzBfRXhlY3V0ZVRpbWVfREVTQ19XZWQgTWFyIDA2IDE0OjM1OjQ3IENTVCAyMDI0Xw==_1709708406465

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "Successful",
  "RequestId": "F43E7FB3-CE67-5FFD-A59C-EFD278BCD7BE",
  "Success": "true",
  "Data": {
    "StartTime": 1596177993000,
    "EndTime": 1608888296000,
    "TotalRecords": 1,
    "Items": {
      "SQLLogRecord": [
        {
          "Ext": "None",
          "ExecuteTime": "2023-12-07T02:15:32Z",
          "OriginTime": 1701886532000,
          "HostAddress": "11.197.XX.XX",
          "UpdateRows": 0,
          "LogicRead": 0,
          "SqlText": "select resource_id as cluster_id, tpl_name \\n\\tfrom dbfree_alert_resource_tpl_ref\\n\\twhere user_id=? and type='cluster' group by resource_id, tpl_name",
          "LockTime": 0,
          "ScanRows": 0,
          "ThreadId": 0,
          "State": "0",
          "DBName": "testdb",
          "SqlType": "select",
          "AccountName": "testname",
          "PhysicSyncRead": 0,
          "PhysicAsyncRead": 0,
          "TrxId": "200000",
          "ReturnRows": 0,
          "Consume": 58,
          "Vip": "100.115.XX.XX",
          "NodeId": "pi-uf6k5f6g3912i****",
          "SqlId": "c67649d4a7fb62c4f8c7a447c52b5b17",
          "UseImciEngine": "true",
          "ParallelQueueTime": "2",
          "ParallelDegree": "10",
          "Scnt": 10,
          "Rows": 10,
          "Frows": 10,
          "TraceId": "14c93b7c7bf00000 ",
          "PhysicRead": 0,
          "CpuTime": 100,
          "Writes": 10,
          "Collection": "None",
          "TableName": ""
        }
      ]
    },
    "Finish": "1",
    "JobId": "MzI4NTZfUUlOR0RBT19DTTlfTlUyMF9NWVNRTF9PREJTX0xWU18zMjg1Nl9teXNxbF9XZWQgTWFyIDA2IDE0OjUwOjQ3IENTVCAyMDI0XzBfMzBfRXhlY3V0ZVRpbWVfREVTQ19XZWQgTWFyIDA2IDE0OjM1OjQ3IENTVCAyMDI0Xw==_1709708406465"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid.
403 NoPermission You are not authorized to do this action.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.