Updated on 2025-05-19 GMT+08:00

Querying SQL Insight Tasks

Function

After Collect All Query Logs is enabled, you can query SQL Insight tasks. This function is available only for paid instances.

URI

GET /v3/{project_id}/instances/{instance_id}/full-sql-tasks

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Explanation:

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

instance_id

Yes

String

Explanation:

Unique ID of an instance

Constraints:

N/A

Values:

The value can contain 32 characters. Only letters and digits are allowed.

Default value:

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

range_left

No

Long

Explanation:

Minimum start time of a task

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

range_right

No

Long

Explanation:

Maximum start time and end time of a task

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

create_at_left

No

Long

Explanation:

Minimum creation time of a task

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

create_at_right

No

Long

Explanation:

Maximum creation time of a task

Constraints:

Unix timestamp, in milliseconds

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

user

No

String

Explanation:

Username

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

keyword

No

String

Explanation:

Keyword

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

db_name

No

String

Explanation:

Database name

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

operation

No

String

Explanation:

Operation type

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

thread_id

No

String

Explanation:

Thread ID

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

trx_id

No

String

Explanation:

Transaction ID

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

status

No

String

Explanation:

Execution status

Constraints:

Multiple values need to be separated by commas (,).

Values:

  • 0: successful
  • 1: failed

Default value:

N/A

sql_template_id

No

String

Explanation:

SQL template ID

Constraints:

Multiple values need to be separated by commas (,).

Values:

N/A

Default value:

N/A

sort_field

No

String

Explanation:

Sorting field

  • create_at: task creation time
  • range_start_at and range_end_at: start time and end time of a task

Constraints:

N/A

Values:

  • create_at: task creation time
  • range_start_at and range_end_at: start time and end time of a task

Default value:

N/A

asc

No

Boolean

Explanation:

Sorting order

Constraints:

N/A

Values:

  • true: ascending
  • false: descending

Default value:

N/A

page

No

Integer

Explanation:

Page number

Constraints:

N/A

Values:

[0, 2^31-1]. The actual value depends on the query result.

Default value:

N/A

limit

No

Integer

Explanation:

Records on each page

Constraints:

N/A

Values:

[0, 100]. The actual value depends on the query result.

Default value:

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

tasks

Array of Table 4 objects

Explanation:

SQL Insight tasks

Values:

N/A

total

Integer

Explanation:

Total number

Values:

N/A

Table 4 FullSqlTask

Parameter

Type

Description

id

Long

Explanation:

Task ID

Values:

N/A

instance_id

String

Explanation:

Instance ID

Values:

N/A

instance_name

String

Explanation:

Instance name

Values:

N/A

node_id

String

Explanation:

Node ID

Values:

N/A

start_at

Long

Explanation:

Start time in the Unix timestamp format, in milliseconds

Values:

N/A

end_at

Long

Explanation:

End time in the Unix timestamp format, in milliseconds

Values:

N/A

batch_id

String

Explanation:

Batch ID

Values:

N/A

user_list

Array of strings

Explanation:

Username

Values:

N/A

keyword

Array of strings

Explanation:

Keyword

Values:

N/A

db_list

Array of strings

Explanation:

Database

Values:

N/A

operation_list

Array of strings

Explanation:

Operation type

Values:

N/A

thread_id_list

Array of strings

Explanation:

Thread ID

Values:

N/A

trx_id_list

Array of strings

Explanation:

Transaction ID

Values:

N/A

status_list

Array of strings

Explanation:

Execution status

Values:

  • 0: successful
  • 1: failed

sql_template_ids

Array of strings

Explanation:

SQL template ID

Values:

N/A

status

Integer

Explanation:

Task status

Values:

  • 0: waiting for parsing
  • 1: parsing
  • 2: parsing completed
  • –1: failed

progress

Double

Explanation:

Task progress

Values:

[0,100]

reason

String

Explanation:

Failure cause

Values:

N/A

create_at

Long

Explanation:

Creation time in the Unix timestamp format, in milliseconds

Values:

N/A

update_at

Long

Explanation:

Update time in the Unix timestamp format, in milliseconds

Values:

N/A

Example Request

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/full-sql-tasks

Example Response

Status code: 200

Successful request

{
  "tasks": [
    {
      "id": 1128,
      "instance_id": "da304cd5bbb944de828759bc7be3d3fein01",
      "start_at": 1738717200000,
      "end_at": 1738720800000,
      "status": 2,
      "progress": 100,
      "create_at": 1738740285113,
      "update_at": 1738740294826
    }
  ],
  "total": 1
}

Status Codes

Status Code

Description

200

Successful request

400

Client error

500

Server error

Error Codes

See Error Codes.