Querying Slow Query Log Statistics
Function
This API is used to query slow query log statistics of a DB instance.
- Before calling this API, learn how to authenticate it.
- Before calling this API, learn about request header parameters.
Authorization Information
- If you are using role/policy-based authorization, see Permissions and Supported Actions for details on the required permissions.
- 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 |
|---|---|---|---|---|---|
|
rds:log:getSlowLogs |
read |
instance |
g:EnterpriseProjectId g:ResourceTag/<tag-key> |
rds:log:list |
- |
URI
- Parameter description
Table 1 Parameters Parameter
Mandatory
Description
project_id
Yes
Definition
Project ID of a tenant in a region.
To obtain the value, see Obtaining a Project ID.
Constraints
N/A
Range
N/A
Default Value
N/A
instance_id
Yes
Definition
ID of the instance to be queried.
Constraints
N/A
Range
N/A
Default Value
N/A
Request
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
start_time |
Yes |
String |
Definition Start time. Constraints N/A Range The value is in the "yyyy-mm-ddThh:mm:ssZ" format. T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800. Default Value N/A |
|
end_time |
Yes |
String |
Definition End time. Constraints You can only query slow logs generated within a month. Range The value is in the "yyyy-mm-ddThh:mm:ssZ" format. T is the separator between the calendar and the hourly notation of time. Z indicates the time zone offset. For example, in the Beijing time zone, the time zone offset is shown as +0800. Default Value N/A |
|
offset |
No |
Integer |
Definition Index offset. Constraints N/A Range An integer greater than or equal to 0 Default Value The default value is 0, indicating that the query starts from the first piece of data. |
|
limit |
No |
Integer |
Definition Number of records (query results) displayed on each page. Constraints N/A Range An integer ranging from 1 to 100 Default Value If this parameter is not specified, the default value 10 is used. |
|
type |
No |
String |
Definition SQL statement type. Constraints N/A Range If this parameter is left blank, all statement types are queried. Enumerated values:
Default Value ALL |
|
database |
No |
String |
Definition Database name. Constraints N/A Range It cannot contain special characters such as < > &. Default Value N/A |
|
sort |
No |
String |
Definition Sorting field. Constraints N/A Range
Default Value Left empty |
|
order |
No |
String |
Definition Sorting sequence. Constraints N/A Range Enumerated values:
Default Value desc |
Example Request
POST https://{endpoint}/v3.1/0483b6b16e954cb88930a360d2c4e663/instances/cee5265e1e5845649e354841234567dfin01/slow-logs/statistics
{
"start_time":"2023-01-05T08:00:00+0800",
"end_time":"2023-01-11T20:00:00+0800",
"limit":10,
"order":"asc"
}
Response
- Normal response
Table 3 Parameters Parameter
Type
Description
slow_log_list
Array of objects
Definition
Data set.
For details, see Table 4.
total_count
Integer
Definition
Total number of records.
Range
N/A
Table 4 slow_log_list field data structure description Parameter
Type
Description
count
String
Definition
Number of executions.
Range
N/A
time
String
Definition
Average execution time, in milliseconds.
Range
N/A
lock_time
String
Definition
Average lock wait time. Only RDS for MySQL supports this parameter.
Range
N/A
rows_sent
Long
Definition
Average number of rows contained in a result. Only RDS for MySQL supports this parameter.
Range
N/A
rows_examined
Long
Definition
Average number of scanned rows. Only RDS for MySQL supports this parameter.
Range
N/A
database
String
Definition
Database which slow logs belong to. If any database name contains special characters such as < > ', the special characters will be escaped.
Range
N/A
users
String
Definition
Account.
Range
N/A
query_sample
String
Definition
Execution syntax.
Range
N/A
client_ip
String
Definition
IP address.
Range
N/A
type
String
Definition
Statement type.
Range
N/A
- Example normal response
{ "slow_log_list" : [ { "count" : "9 (100.00%)", "time" : "3.00018 s", "lock_time" : "0.00000 s", "rows_sent" : 1, "rows_examined" : 0, "database" : "test_db", "users" : "root", "query_sample" : "SELECT sleep(N) LIMIT N, N;", "client_ip" : "100.*.*.247", "type" : "SELECT" } ], "total_count" : 1 } - Abnormal response
For details, see Abnormal Request Results.
Status Code
- Normal
- Abnormal
For details, see Status Codes.
Error Code
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank 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