Exporting Slow Query Log Statistics
Function
This API is used to export slow query log statistics after Collect Slow Query Logs is enabled.
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::showCloudDBAInfo
Read
-
-
-
-
URI
POST /v3/{project_id}/instances/{instance_id}/slow-sql-statistics
| 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. Only letters and digits are supported. Default Value N/A |
| instance_id | Yes | String | Definition Instance ID, which uniquely identifies an instance. You can obtain the instance ID from the instance list or instance details. Constraints N/A Range The value can contain 36 characters. Only letters and digits are allowed. Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| datastore_type | Yes | String | Definition Database type Constraints N/A Range
Default Value N/A |
| start_at | Yes | Long | Definition Start time Constraints Unix timestamp, in milliseconds Range [0, 2^63 – 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^63 – 1]. The actual value depends on the query result. Default Value N/A |
| node_ids | No | Array of strings | Definition Unique IDs of nodes. You can obtain the node IDs from the node list in the instance details. The value can contain 36 characters. Only letters and digits are allowed. Constraints Multiple values need to be separated by commas (,). |
| statistics_field | No | String | Definition Statistics field Constraints N/A Range
Default Value node_id |
| offset | No | Integer | Definition 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 Range [0, 2^31-1] Default Value 0: The query starts from the first data record. |
| limit | No | Integer | Definition Number of records on each page Constraints N/A Range [1, 100] Default Value 20 |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| statistics_list | Array of Table 4 objects | Definition Slow SQL statement statistics |
| total_count | Integer | Definition Total number Range [0, 2^31-1] |
| Parameter | Type | Description |
|---|---|---|
| execute_count | Long | Definition Execution times Range N/A |
| avg_execute_time | Double | Definition Average execution duration (s) Range N/A |
| max_execute_time | Double | Definition Maximum execution duration (s) Range N/A |
| avg_lock_wait_time | Double | Definition Average lock wait time (s) Range N/A |
| max_lock_wait_time | Double | Definition Maximum lock wait time (s) Range N/A |
| avg_rows_sent | Double | Definition Average number of returned documents Range N/A |
| max_rows_sent | Double | Definition Maximum number of returned documents Range N/A |
| avg_rows_examined | Double | Definition Average number of scanned documents Range N/A |
| max_rows_examined | Double | Definition Maximum number of scanned documents Range N/A |
| avg_key_examined | Double | Definition Average number of scanned indexes Range N/A |
| max_key_examined | Double | Definition Maximum number of scanned indexes Range N/A |
| node_id | String | Definition Node ID, which is assigned when statistics_field is set to node_id You can obtain the node ID from the node list in the instance details. The value can contain 36 characters. Only letters and digits are allowed. Range N/A |
| node_name | String | Definition Node name, which is assigned when statistics_field is set to node_id Range N/A |
| sql_type | String | Definition Statement type, which is assigned when statistics_field is set to sql_type Range N/A |
| db_name | String | Definition Database name, which is assigned when statistics_field is set to db_name or collection Range N/A |
| collection | String | Definition Database table, which is assigned when statistics_field is set to collection Range N/A |
| user | String | Definition Username, which is assigned when statistics_field is set to user Range N/A |
| client | String | Definition Client which is assigned when statistics_field is set to client Range N/A |
Example Requests
Exporting slow query logs
POST https://das.cn-north-1.myhuaweicloud.com/v3/054c630ff780d4cc2f40c00d7f6fb21d/instances/6243b3fcf2f948578d46ed4c52fb54eein02/slow-sql-statistics
{
"datastore_type": "DDS-Community",
"start_at": 1782974538510,
"end_at": 1782985338510,
"statistics_field": "client"
} Example Responses
Status code: 200
Success.
{ "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 response |
| 400 | Client error |
| 500 | Server error |
Error Codes
See Error Codes.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot