DescribeSqlLogRecords

Updated at:

Queries the log details of DAS Enterprise Edition.

Operation description

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

  • Use the latest version of the Alibaba Cloud or DAS SDK.

  • When you use an SDK to call DAS, 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 Edition 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 (compute node) or polarx_dn (data node).

pi-uf6k5f6g3912i****

Role

string

No

The role of the node in the PolarDB-X 2.0 instance. Valid values:

  • polarx_cn: compute node.

  • polarx_dn: data node.

polarx_cn

Filters

array<object>

No

The list of filter conditions.

object

No

The filter condition.

Key

string

No

The filter parameter.

Note

For supported filter parameters and their valid values, refer to Supplementary request parameter descriptions.

keyWords

Value

string

No

The value of the filter parameter.

select

StartTime

integer

Yes

The start time. The value is a UNIX timestamp in milliseconds.

1596177993000

EndTime

integer

Yes

The end time. The value is a UNIX timestamp in milliseconds.

1608888296000

PageNo

integer

No

The page number for paging. Pages start from 1. Default value: 1.

1

PageSize

integer

No

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

10

The parameters and values supported by Key are as follows:

  • KeyWords: The keywords. Separate multiple keywords with spaces.

  • LogicalOperator: The logical operator between keywords. Valid values: and and or.

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

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

  • HostAddress: The client IP address. 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 statement type. Valid values: select, update, insert, and delete.

  • State: The execution result. Valid values: 0 (success) and 1 (failure).

  • ThreadId: The thread ID.

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

  • SortMethod: The sort order. Valid values: DESC (descending order) and ASC (ascending order). Default value: DESC.

  • TraceId: The trace ID of the 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 to the data node (DN) from the compute node (CN) of PolarDB-X 2.0.

  • MaxScnt: The maximum number of requests to the data node (DN) from the compute node (CN) of PolarDB-X 2.0.

  • TrxId: The transaction ID.

  • Fail: The error code.

  • SqlId: The SQL ID.

  • JobId: The ID of the asynchronous task used to further query the returned results.

Response elements

Element

Type

Description

Example

object

The root node.

Code

string

The returned HTTP status code.

200

Message

string

The returned message.

Note

If the request is successful, Successful is returned. If the request fails, an error message such as an error code is returned.

Successful

RequestId

string

The request ID.

F43E7FB3-CE67-5FFD-A59C-EFD278BCD7BE

Success

string

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

Data

object

The returned data.

StartTime

integer

The start time. The value is a UNIX timestamp in milliseconds.

1596177993000

EndTime

integer

The end time. The value is a UNIX timestamp in milliseconds.

1608888296000

TotalRecords

integer

The total number of records.

1

Items

object

The list data.

SQLLogRecord

array<object>

The SQL log data.

object

The SQL log data.

Ext

string

The extended information field. This is a reserved parameter.

None

ExecuteTime

string

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

2023-12-07T02:15:32Z

OriginTime

integer

The execution timestamp. The value is a UNIX timestamp in milliseconds.

1701886532000

HostAddress

string

The IP address of the client.

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 in milliseconds.

0

ScanRows

integer

The number of scanned rows.

0

ThreadId

integer

The thread ID.

None

State

string

The execution status. Valid values:

  • 0: The execution was successful.

  • 1: The execution failed.

0

DBName

string

The name of the database.

testdb

SqlType

string

The type of the SQL statement.

select

AccountName

string

The database account.

testname

PhysicSyncRead

integer

The number of physical synchronous reads.

0

PhysicAsyncRead

integer

The number of physical asynchronous reads.

0

TrxId

string

The transaction ID.

200000

ReturnRows

integer

The number of returned rows.

0

Consume

integer

The execution duration in microseconds.

58

Vip

string

The resolved endpoint address of the query connection.

100.115.XX.XX

NodeId

string

The node ID.

pi-uf6k5f6g3912i****

SqlId

string

The SQL ID.

c67649d4a7fb62c4f8c7a447c52b5b17

UseImciEngine

string

Indicates whether the PolarDB for MySQL instance uses IMCI. Valid values:

  • true: Yes.

  • false: No.

true

ParallelQueueTime

string

The degree of parallelism of the PolarDB for MySQL instance.

2

ParallelDegree

string

The parallel queue time of the PolarDB for MySQL instance in milliseconds.

10

Scnt

integer

The number of requests from the compute node (CN) to the data node (DN) in PolarDB-X 2.0.

10

Rows

integer

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

10

Frows

integer

The number of rows pulled by the compute node (CN) in PolarDB-X 2.0.

10

TraceId

string

The trace ID in PolarDB-X 2.0, which is the execution ID of the SQL statement on the data node.

14c93b7c7bf00000

PhysicRead

integer

The number of physical reads.

0

CpuTime

integer

The CPU execution time in microseconds.

100

Writes

integer

The number of writes for the ApsaraDB RDS for SQL Server engine.

10

Collection

string

The reserved parameter.

None

TableName

string

The table name in the SQL log record.

das

ConnectionId

string

The connection ID of the SQL log record.

ld-******

Protocol

string

The protocol type of the SQL log record.

MySQL

Params

string

The parameters of the SQL log record.

[1, "das"]

ClientIp

string

The client IP address in the SQL log record. The IP address of the client in the SQL log record.

10.0.0.1xx

ClientPort

integer

The port number of the client.

3306

RowKey

string

The row key of the SQL log record.

23

AffectColumns

string

The affected columns.

["col1"]

Finish

string

Indicates whether the task is completed. Valid values:

  • 0: Not completed.

  • 1: Completed.

Note

If Finish is 0 and the JobId field is included, the current request is an asynchronous request and the result cannot be directly obtained. You must query the result based on JobId. When you query the result, use JobId as the input value for Filters. Example: Filters=[{"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": "das",
          "ConnectionId": "ld-******",
          "Protocol": "MySQL",
          "Params": "[1, \"das\"]",
          "ClientIp": "10.0.0.1xx",
          "ClientPort": 3306,
          "RowKey": "23",
          "AffectColumns": "[\"col1\"]"
        }
      ]
    },
    "Finish": "1",
    "JobId": "MzI4NTZfUUlOR0RBT19DTTlfTlUyMF9NWVNRTF9PREJTX0xWU18zMjg1Nl9teXNxbF9XZWQgTWFyIDA2IDE0OjUwOjQ3IENTVCAyMDI0XzBfMzBfRXhlY3V0ZVRpbWVfREVTQ19XZWQgTWFyIDA2IDE0OjM1OjQ3IENTVCAyMDI0Xw==_1709708406465"
  }
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidParams The request parameters are invalid. The request parameters are invalid.
403 NoPermission You are not authorized to do this action. You do not have the permission to perform this operation.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.