Updated on 2026-01-20 GMT+08:00

Exporting All Query Logs

Function

After Collect All Query Logs is enabled, you can export all query logs within a specified period. The data can be obtained by page. This function is available only for paid instances.

Authorization Information

Each account has permissions to call all APIs, but IAM users must have the required permissions specifically assigned.

  • If you are using role/policy-based authorization, see the required permissions in Permissions Policies and Supported Actions.
  • If you are using identity policy-based authorization, the following identity policy-based permissions are required.

    Action

    Access Level

    Resource Type (*: required)

    Condition Key

    Alias

    Dependencies

    das:clouddba:fullSqlExport

    List

    Instance

    -

    -

    -

URI

GET /v3/{project_id}/instances/{instance_id}/sql-statements

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Definition

Project ID of a tenant in a region

To obtain this value, see Obtaining a Project ID.

Constraints

N/A

Range

The value can contain 32 characters, including only letters and digits.

Default Value

N/A

instance_id

Yes

String

Definition

Unique ID of an instance

Constraints

N/A

Range

The value can contain 32 characters, including only letters and digits.

Default Value

N/A

Table 2 Query parameters

Parameter

Mandatory

Type

Description

start_at

Yes

Long

Definition

Start time

Constraints

Unix timestamp, in milliseconds

Range

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

Default Value

N/A

end_at

Yes

Long

Definition

End time

Constraints

Unix timestamp, in milliseconds

Range

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

Default Value

N/A

limit

Yes

Integer

Definition

Records on each page

Constraints

N/A

Range

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

Default Value

N/A

marker

No

String

Definition

Query result marker. When the first page is obtained, no value needs to be assigned to this parameter. When the next page is obtained, the returned value of the first page query result is used.

Constraints

N/A

Range

N/A

Default Value

N/A

datastore_type

Yes

String

Definition

Database type

Constraints

N/A

Range

  • MySQL
  • TaurusDB

Default Value

N/A

Request Parameters

None

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

statements

Array of FullSql objects

Definition

All query logs. If the set is empty, all query logs have been exported.

Range

N/A

next_marker

String

Definition

Marker required for obtaining the next page. This parameter is valid only within 3 minutes.

Range

N/A

Table 4 FullSql

Parameter

Type

Description

sql

String

Definition

SQL statement

Range

N/A

operate_type

String

Definition

Operation type

Range

  • insert
  • delete
  • update
  • select
  • show
  • create
  • drop
  • alter
  • set
  • replace
  • use
  • start: Start a transaction.
  • commit: Commit a transaction.
  • rollback: Roll back a transaction.
  • truncate
  • begin: Start a transaction.
  • call: Call a stored procedure.

status

String

Definition

Status

Range

  • 0: The SQL statement is successfully executed.
  • 1: The SQL statement failed to be executed.

error_no

String

Definition

Error code

Range

N/A

database

String

Definition

Database name

Range

N/A

client

String

Definition

Client

Range

N/A

thread_id

String

Definition

Thread ID

Range

N/A

user

String

Definition

User

Range

N/A

execute_at

Long

Definition

Execution start time in the Unix timestamp format, in milliseconds

Range

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

query_time

Double

Definition

Execution duration, in milliseconds

Range

N/A

lock_time

Double

Definition

Lock wait time (ms)

Range

N/A

rows_examined

Long

Definition

Number of scanned rows

Range

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

rows_sent

Long

Definition

Returned rows

Range

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

rows_affected

Long

Definition

Updated rows

Range

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

Example Requests

Exporting all query logs

GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/sql-statements?start_at=1611975464337&end_at=1611979064337&limit=10&marker=DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAQH8YWSEFfM3FyOXZRNzJQOTVLNHNBOTQ2UQ==&datastore_type=MySQL

Example Responses

Status code: 200

Response body for exporting all query logs

{
  "statements" : [ {
    "sql" : "SELECT 1",
    "operate_type" : "select",
    "status" : "success",
    "error_no" : "",
    "database" : "",
    "thread_id" : "11481954",
    "client" : "100.79.3.154",
    "user" : "root",
    "execute_at" : 1612403000100,
    "query_time" : 0,
    "lock_time" : 0,
    "rows_examined" : 0,
    "rows_sent" : 1,
    "rows_affected" : 0
  } ],
  "next_marker" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAASG3cWcHVpdktBU1lTbjJMM2tmYXYxZ09nUQ=="
}

Status Codes

Status Code

Description

200

Response body for exporting all query logs

400

Client error

500

Server error

Error Codes

See Error Codes.