Querying Slow Query Log Statistics
Function
This API is used to query slow query log statistics. Before calling this API:
- Learn how to authenticate it.
- Obtain the required region and endpoint.
URI
POST /v3/{project_id}/instances/{instance_id}/slow-logs/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 contains 32 characters. Only letters and digits are allowed. Default Value N/A |
| instance_id | Yes | String | Definition Instance ID, which uniquely identifies an instance. Constraints N/A Range The value contains 36 characters with a suffix of in07. Only letters and digits are allowed. Default Value N/A |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| X-Auth-Token | Yes | String | Definition User token. To obtain this value, call the IAM API for obtaining a user token. The value of X-Subject-Token in the response header is the token value. Constraints N/A Range N/A Default Value N/A |
| X-Language | No | String | Definition Request language type. Constraints N/A Range Default Value en-us |
Response Parameters
Status code: 200
| Parameter | Type | Description |
|---|---|---|
| slow_log_list | Array of ShowSlowLogStatisticsItem objects | Definition List of slow query log statistics. |
| total_count | Integer | Definition Total records. Range N/A |
| Parameter | Type | Description |
|---|---|---|
| client_ip | String | Definition IP address. Default Value N/A |
| count | String | Definition Number of executions. Default Value N/A |
| database | String | Definition Database that slow query logs belong to. Default Value N/A |
| lock_time | String | Definition Average lock wait time. Default Value N/A |
| node_id | String | Definition Node ID. Default Value Same as the input parameter |
| query_sample | String | Definition Execution syntax. Default Value N/A |
| rows_examined | Integer | Definition Average number of scanned rows. Default Value N/A |
| rows_sent | Integer | Definition Average number of rows contained in a result. Default Value N/A |
| time | String | Definition Average execution duration. Default Value N/A |
| type | String | Definition Statement type. Default Value |
| users | String | Definition Account. Default Value N/A |
Status code: 400
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error message. |
Status code: 500
| Parameter | Type | Description |
|---|---|---|
| error_code | String | Error code. |
| error_msg | String | Error message. |
Example Request
Querying slow query log statistics
POST https://{endpoint}/v3/054e292c9880d4992f02c0196d3ea468/instances/6754902da1f447269c6979b0590102a5in07/slow-logs/statistics
{
"limit" : 10,
"offset" : 0,
"node_id" : "4006312b96c541749d735c20e86dd169no07",
"type" : null,
"database" : null,
"start_time" : "2024-08-16T14:37:00+0800",
"end_time" : "2024-08-16T16:51:22+0800",
"sort" : null,
"order" : "desc"
} Example Response
Status code: 200
Success.
{
"slow_log_list" : [ {
"node_id" : "4006312b96c541749d735c20e86dd169no07",
"count" : "1 (100.00%)",
"time" : "11.00014 s",
"lock_time" : "0.00000 s",
"rows_sent" : 1,
"rows_examined" : 1,
"database" : "",
"users" : "root",
"query_sample" : "select sleep(N);",
"client_ip" : "localhost",
"type" : "SELECT"
} ],
"total_count" : 1
} Status Code
For details, see Status Codes.
Error Code
For details, see Error Codes.