Help Center/ Data Admin Service/ API Reference/ APIs (in OBT)/ Intelligent O&M/ Exporting Slow Query Log Statistics
Updated on 2025-11-24 GMT+08:00

Exporting Slow Query Log Statistics

Function

This API is used to export slow query log statistics after Collect Slow Query Logs is enabled.

URI

POST /v3/{project_id}/instances/{instance_id}/slow-sql-statistics

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

Request Parameters

Table 2 Request body parameters

Parameter

Mandatory

Type

Description

datastore_type

Yes

String

Explanation:

Database type

Constraints:

N/A

Values:

  • DDS-Community

Default value:

N/A

start_at

Yes

Long

Explanation:

Start time

Constraints:

Unix timestamp, in milliseconds

Values:

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

Default value:

N/A

end_at

Yes

Long

Explanation:

End time

Constraints:

Unix timestamp, in milliseconds

Values:

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

Default value:

N/A

node_ids

No

Array of strings

Explanation:

Node ID list

Constraints:

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

Values:

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

Default value:

N/A

statistics_field

No

String

Explanation:

Statistics field

Constraints:

N/A

Values:

  • node_id
  • sql_type
  • db_name
  • collection
  • user
  • client

Default value:

node_id

offset

No

Integer

Explanation:

Index offset. The query starts from the next piece of data indexed by this parameter. If this parameter is set to 1 and limit is set to 10, only the second to eleventh records are displayed.

Constraints:

N/A

Values:

[0, 2^31-1]

Default value:

0: The query starts from the first data record.

limit

No

Integer

Explanation:

Records on each page

Constraints:

N/A

Values:

[1, 100]

Default value:

20

Response Parameters

Status code: 200

Table 3 Response body parameters

Parameter

Type

Description

statistics_list

Array of Table 4 objects

Explanation:

Slow SQL statement statistics

Values:

N/A

total_count

Integer

Explanation:

Total number

Values:

[0, 2^31-1]

Table 4 SlowSqlStatistics

Parameter

Type

Description

execute_count

Long

Explanation:

Execution times

Values:

N/A

avg_execute_time

Double

Explanation:

Average execution duration (s)

Values:

N/A

max_execute_time

Double

Explanation:

Maximum execution duration (s)

Values:

N/A

avg_lock_wait_time

Double

Explanation:

Average lock wait time (s)

Values:

N/A

max_lock_wait_time

Double

Explanation:

Maximum lock wait time (s)

Values:

N/A

avg_rows_sent

Double

Explanation:

Average number of returned documents

Values:

N/A

max_rows_sent

Double

Explanation:

Maximum number of returned documents

Values:

N/A

avg_rows_examined

Double

Explanation:

Average number of scanned documents

Values:

N/A

max_rows_examined

Double

Explanation:

Maximum number of scanned documents

Values:

N/A

avg_key_examined

Double

Explanation:

Average number of scanned indexes

Values:

N/A

max_key_examined

Double

Explanation:

Maximum number of scanned indexes

Values:

N/A

node_id

String

Explanation:

Node ID, which is assigned when statistics_field is set to node_id

Values:

N/A

node_name

String

Explanation:

Node name, which is assigned when statistics_field is set to node_id

Values:

N/A

sql_type

String

Explanation:

Statement type, which is assigned when statistics_field is set to sql_type

Values:

N/A

db_name

String

Explanation:

Database name, which is assigned when statistics_field is set to db_name or collection

Values:

N/A

collection

String

Explanation:

Database table, which is assigned when statistics_field is set to collection

Values:

N/A

user

String

Explanation:

Username, which is assigned when statistics_field is set to user

Values:

N/A

client

String

Explanation:

Client, which is assigned when statistics_field is set to client

Values:

N/A

Example Request

Exporting slow query logs

"POST  https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein02/slow-sql-statistics"

Example Response

Status code: 200

Successful request

{  "statistics_list": [
{
"execute_count": 6,
"avg_execute_time": 5.000509315066868,
"max_execute_time": 5.008123874664307,
"avg_lock_wait_time": 1,
"max_lock_wait_time": 1,
"avg_rows_sent": 1,
"max_rows_sent": 1,
"avg_rows_examined": 0,
"max_rows_examined": 0,
"avg_key_examined": 0,
"max_key_examined": 0,
"node_id": "fec05693c76c4f389561051db430324cno02",
"node_name": "dds-1234_node_1"
}
],
"total_count": 1
}

Status Codes

Status Code

Description

200

Successful request

400

Client error

500

Server error

Error Codes

See Error Codes.