All Products
Search
Document Center

Database Autonomy Service:DescribeSqlLogTask

更新时间:Jul 23, 2025

Queries the details of an offline task created by DAS Enterprise Edition.

Operation description

You can use this API to retrieve the status and results of an offline SQL log task. A task can be one of two types:

  • Query: An in-place query whose results are returned directly in the Queries array.

  • Export: A task that generates a downloadable file of SQL logs. The result is a download URL.

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

  • SDK version: Use the latest version of the Alibaba Cloud SDK.

  • Region: If you call the API via the SDK, set the region ID 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 support 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 ID of the database instance.

r-bp1nti25tc7bq5****

TaskId

string

No

The ID of the offline task to query.

a4f5c4494dbd6713185d87a97aa53e8

PageNo

integer

No

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

1

PageSize

integer

No

The number of entries to return on each page. Maximum value: 100. Default value: 10.

10

Response parameters

Parameter

Type

Description

Example

object

Code

string

The status code. 200 indicates success.

200

Message

string

The response message.

Note
  • When the request is successful, this parameter returns Successful. When the request fails, this parameter returns exception information such as error codes.

Successful

RequestId

string

The unique 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

An object containing the task details. See below.

Name

string

The task name.

SQL审计导出1

TaskId

string

The task ID.

9a4f5c4494dbd6713185d87a97aa53e8

TaskType

string

The task type.

  • Export: export task.

  • Query: query task.

Query

CreateTime

integer

The time when the task was created. The value is a UNIX timestamp. Unit: milliseconds.

1681363254423

Status

string

The task status.

  • INIT: pending scheduling.

  • RUNNING: running.

  • FAILED: failed.

  • CANCELED: canceled.

  • COMPLETED: completed.

Note

When the task is in the COMPLETED state, you can view the results of the offline task.

COMPLETED

Expire

boolean

Indicates whether the task has expired.

  • true: yes.

  • false: no.

false

Start

integer

The start time of the query. The value is a UNIX timestamp. Unit: milliseconds.

1596177993000

End

integer

The end time of the query. The value is a UNIX timestamp. Unit: milliseconds.

1608888296000

Filters

array

The filter conditions.

object

The query filter conditions.

Key

string

The name of the filter parameter.

Note

For information about the supported filter parameters and their values, see Additional description of response parameters.

keyWords

Value

any

The value of the filter parameter.

select

Total

integer

The total number of tasks.

1

Queries

array

(If TaskType is Query) An array of objects, where each object is a SQL log record. See Queries Object Structure below.

object

The results of the offline query task.

Vip

string

The endpoint resolution address of the query link.

10.146.XX.XX

NodeId

string

The child 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 result.

  • 0: The execution was successful.

  • 1: The execution failed.

0

DBName

string

The database name.

testdb01

SqlId

string

The ID of the SQL statement.

a4111670e80596c5bf42cf5154438a91

ExecuteTime

string

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

2023-12-07T02:15:32Z

OriginTime

integer

The execution timestamp. The value is a UNIX timestamp. Unit: milliseconds.

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 duration. Unit: milliseconds.

0

UpdateRows

integer

The number of rows updated.

0

ScanRows

integer

The number of rows scanned.

0

ReturnRows

integer

The number of rows returned.

0

LogicRead

integer

The logical read.

0

PhysicSyncRead

integer

The physical read-through.

0

PhysicAsyncRead

integer

The physical asynchronous read.

0

ThreadId

integer

The thread ID.

None

TrxId

string

The transaction ID.

200000

Ext

string

The extension information field, which is a reserved parameter.

None

Scnt

integer

The number of requests from the CNs to the DNs in the PolarDB-X 2.0 instance.

10

Rows

integer

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

10

Frows

integer

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

10

TraceId

string

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

14c93b7c7bf00000

UseImciEngine

string

Indicates whether the PolarDB for MySQL instance uses In-Memory Column Index.

  • true: yes.

  • false: no.

true

ParallelDegree

string

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

10

ParallelQueueTime

string

The degree of parallelism of the PolarDB for MySQL instance.

2

PhysicRead

integer

The physical read.

0

CpuTime

integer

The CPU execution time. Unit: microseconds.

100

Writes

integer

The number of writes in the RDS SQL Server engine.

10

Collection

string

Reserved parameter

None

SqlCommand

integer

Export

string

(If TaskType is Export) A temporary URL to download the exported SQL log file.

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

Key supports the following parameters and values:

  • KeyWords: keywords. Multiple keywords are separated by spaces.

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

  • AccountName: the username. You can specify multiple usernames separated by commas. Maximum number: 5.

  • dbName: the database name. You can specify multiple database names separated by commas. Maximum number: 5.

  • HostAddress: the client IP address. You can specify multiple IP addresses separated by commas. Maximum number: 5.

  • MaxConsume: the maximum execution duration. Unit: microseconds.

  • MinConsume: the minimum execution duration. Unit: microseconds.

  • MaxScanRows: the maximum number of rows scanned.

  • MinScanRows: the minimum number of rows scanned.

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

  • State: the execution result. Valid values: 0 (successful) and 1 (failed).

  • ThreadId: the thread ID.

  • SortKey: the name of the column for sorting. Valid values: ScanRows (number of rows scanned), UpdateRows (number of rows updated), Consume (execution duration), ExecuteTime (execution time), ReturnRows (number of rows returned), LockTime (lock wait duration), Frows (number of rows pulled by the CNs of the PolarDB-X 2.0 instance), Scnt (number of requests from the CNs to the DNs in the PolarDB-X 2.0 instance), CpuTime (CPU execution time), and PhysicalRead (physical read).

  • SortMethod: the sorting method. 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 rows updated.

  • MaxRows: the maximum number of rows updated.

  • MinScnt: the minimum number of requests from the CNs to the DNs in the PolarDB-X 2.0 instance.

  • MaxScnt: the maximum number of requests from the CNs to the DNs in the 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
      }
    ],
    "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.