DescribeSqlLogTask

更新时间:
复制 MD 格式

Call the DescribeSqlLogTask operation to query the details of an offline task in DAS enterprise edition.

Operation description

Note the following before you call this operation:

  • We recommend using the latest version of the Alibaba Cloud SDK or DAS SDK.

  • When calling the DAS service with an SDK, 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:DescribeSqlLogTask

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

InstanceId

string

No

The database instance ID.

r-bp1nti25tc7bq5****

TaskId

string

No

The task ID.

a4f5c4494dbd6713185d87a97aa53e8

PageNo

integer

No

The page number. Pages are numbered starting from 1. Default value: 1.

1

PageSize

integer

No

The page size. Maximum value: 100. Default value: 10.

10

Response elements

Element

Type

Description

Example

object

The root node of the response.

Code

string

The returned HTTP status code.

200

Message

string

The response message.

Note

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

Successful

RequestId

string

The request ID.

B6D17591-B48B-4D31-9CD6-9B9796B2****

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.

Name

string

The task name.

SQL审计导出1

TaskId

string

The task ID.

9a4f5c4494dbd6713185d87a97aa53e8

TaskType

string

The task type. Valid values:

  • Export: an export task.

  • Query: a query task.

Query

CreateTime

integer

The time when the task was created, which is a UNIX timestamp in milliseconds.

1681363254423

Status

string

The task status. Valid values:

  • INIT: The task is pending.

  • RUNNING: The task is running.

  • FAILED: The task failed.

  • CANCELED: The task was canceled.

  • COMPLETED: The task is complete.

Note

The results of an offline task are available only when the status is COMPLETED.

COMPLETED

Expire

boolean

Indicates whether the task has expired. Valid values:

  • true: The task has expired.

  • false: The task has not expired.

false

Start

integer

The beginning of the query time range, which is a UNIX timestamp in milliseconds.

1596177993000

End

integer

The end of the query time range, which is a UNIX timestamp in milliseconds.

1608888296000

Filters

array<object>

The filter conditions.

object

A query filter condition.

Key

string

The name of the filter parameter.

Note

For more information about the supported filter parameters and their valid values, see the "Additional information about response parameters" section.

keyWords

Value

any

The value of the filter parameter.

select

Total

integer

The total number of tasks.

1

Queries

array<object>

The results of the offline query task. This parameter is returned only if the value of TaskType is Query.

object

The result of the offline query task.

Vip

string

The IP address that the query endpoint resolves to.

10.146.XX.XX

NodeId

string

The node ID.

pi-bp1o58x3ib7e6****

SqlText

string

The SQL statement.

SELECT @@session.transaction_read_only

SqlType

string

The type of the SQL statement. Valid values:

  • SELECT

  • UPDATE

  • DELETE

SELECT

State

string

The execution state. Valid values:

  • 0: The execution was successful.

  • 1: The execution failed.

0

DBName

string

The database name.

testdb01

SqlId

string

The SQL ID.

a4111670e80596c5bf42cf5154438a91

ExecuteTime

string

The time when the SQL statement was executed. The time is in the yyyy-MM-ddTHH:mm:ssZ format. The time is displayed in UTC.

2023-12-07T02:15:32Z

OriginTime

integer

The time when the SQL statement was executed. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since January 1, 1970, 00:00:00 UTC.

1701886532000

AccountName

string

The database account.

testname

HostAddress

string

The client IP address.

11.197.XX.XX

Consume

integer

The execution duration. Unit: milliseconds.

58

LockTime

integer

The lock wait time. Unit: milliseconds.

0

UpdateRows

integer

The number of updated rows.

0

ScanRows

integer

The number of scanned rows.

0

ReturnRows

integer

The number of returned rows.

0

LogicRead

integer

The number of logical reads.

0

PhysicSyncRead

integer

The number of physical synchronous reads.

0

PhysicAsyncRead

integer

The number of physical asynchronous reads.

0

ThreadId

integer

The thread ID.

None

TrxId

string

The transaction ID.

200000

Ext

string

Reserved for future use.

None

Scnt

integer

The number of requests that are sent from compute nodes (CNs) to data nodes (DNs) for a PolarDB-X 2.0 instance.

10

Rows

integer

The total number of rows that are updated or returned by the compute nodes of a PolarDB-X 2.0 instance.

10

Frows

integer

The number of rows that are fetched by the compute nodes of a PolarDB-X 2.0 instance.

10

TraceId

string

The trace ID of a PolarDB-X 2.0 instance. The trace ID is the execution ID of the SQL statement on data nodes.

14c93b7c7bf00000

UseImciEngine

string

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

  • true

  • false

true

ParallelDegree

string

The degree of parallelism (DOP) for the PolarDB for MySQL instance.

10

ParallelQueueTime

string

The parallel queuing time for the PolarDB for MySQL instance. Unit: milliseconds.

2

PhysicRead

integer

The number of physical reads.

0

CpuTime

integer

The CPU execution time. Unit: microseconds.

100

Writes

integer

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

10

Collection

string

This parameter is reserved.

None

SqlCommand

integer

The SQL command in the query.

sql

ConnectionId

string

The connection ID.

ld-******

Protected

string

Indicates whether the query is protected.

MySQL

Params

string

The query parameters.

[1, "das"]

ClientIp

string

The client IP address.

10.0.0.1xx

ClientPort

integer

The client port.

3306

RowKey

string

The row key.

23

AffectColumns

string

The affected columns.

["col1"]

TableName

string

The table name.

das

Export

string

The download URL of the exported file. This parameter is returned only if the value of TaskType is Export.

"https://das-sqllog-download-cn-hongkong.oss-cn-hongkong.aliyuncs.com/****"

The Key parameter supports the following keys:

  • KeyWords: Keywords. Separate multiple keywords with spaces.

  • LogicalOperator: The logical operator for combining keywords. Valid values: and or 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 client IP addresses, separated by commas (,).

  • MaxConsume: Maximum execution duration, in microseconds (μs).

  • MinConsume: Minimum execution duration, in microseconds (μs).

  • MaxScanRows: Maximum number of scanned rows.

  • MinScanRows: Minimum number of scanned rows.

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

  • State: The execution result. Valid values: 0 (successful) or 1 (failed).

  • ThreadId: The thread ID.

  • SortKey: The sort key. 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 fetched by compute nodes of a PolarDB-X 2.0 instance), Scnt (number of requests sent from compute nodes to data nodes of a PolarDB-X 2.0 instance), CpuTime (CPU execution time), and PhysicalRead (number of physical reads).

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

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

  • MinRows: Minimum number of updated rows.

  • MaxRows: Maximum number of updated rows.

  • MinScnt: Minimum number of requests sent from compute nodes (CN) to data nodes (DN) for a PolarDB-X 2.0 instance.

  • MaxScnt: Maximum number of requests sent from compute nodes (CN) to data nodes (DN) for a PolarDB-X 2.0 instance.

  • TrxId: The transaction ID.

  • Fail: The error code.

  • SqlId: The SQL ID.

Examples

Success response

JSON format

{
  "Code": "200",
  "Message": "Successful",
  "RequestId": "B6D17591-B48B-4D31-9CD6-9B9796B2****",
  "Success": "true",
  "Data": {
    "Name": "SQL审计导出1\n",
    "TaskId": "9a4f5c4494dbd6713185d87a97aa53e8\n",
    "TaskType": "Query",
    "CreateTime": 1681363254423,
    "Status": "COMPLETED",
    "Expire": true,
    "Start": 1596177993000,
    "End": 1608888296000,
    "Filters": [
      {
        "Key": "keyWords\n",
        "Value": "select"
      }
    ],
    "Total": 1,
    "Queries": [
      {
        "Vip": "10.146.XX.XX",
        "NodeId": "pi-bp1o58x3ib7e6****\n",
        "SqlText": "SELECT @@session.transaction_read_only",
        "SqlType": "SELECT",
        "State": "0",
        "DBName": "testdb01",
        "SqlId": "a4111670e80596c5bf42cf5154438a91",
        "ExecuteTime": "2023-12-07T02:15:32Z",
        "OriginTime": 1701886532000,
        "AccountName": "testname\n",
        "HostAddress": "11.197.XX.XX\n",
        "Consume": 58,
        "LockTime": 0,
        "UpdateRows": 0,
        "ScanRows": 0,
        "ReturnRows": 0,
        "LogicRead": 0,
        "PhysicSyncRead": 0,
        "PhysicAsyncRead": 0,
        "ThreadId": 0,
        "TrxId": "200000\n",
        "Ext": "None",
        "Scnt": 10,
        "Rows": 10,
        "Frows": 10,
        "TraceId": "14c93b7c7bf00000 ",
        "UseImciEngine": "true\n",
        "ParallelDegree": "10\n",
        "ParallelQueueTime": "2",
        "PhysicRead": 0,
        "CpuTime": 100,
        "Writes": 10,
        "Collection": "None",
        "SqlCommand": 0,
        "ConnectionId": "ld-******",
        "Protected": "MySQL",
        "Params": "[1, \"das\"]",
        "ClientIp": "10.0.0.1xx",
        "ClientPort": 3306,
        "RowKey": "23",
        "AffectColumns": "[\"col1\"]",
        "TableName": "das"
      }
    ],
    "Export": "\"https://das-sqllog-download-cn-hongkong.oss-cn-hongkong.aliyuncs.com/****\""
  }
}

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.