Querying Database Slow Logs¶
Function¶
This API is used to query the latest 2000 database slow query logs.
Before calling an API, you need to understand the API in Authentication.
Before calling this API, obtain the required region and endpoint.
URI¶
URI format
GET https://{Endpoint}/v3/{project_id}/instances/{instance_id}/slowlog?start_date={start_date}&end_date={end_date}
Parameter description
¶ Name
Mandatory
Description
project_id
Yes
Specifies the project ID of a tenant in a region.
For details about how to obtain the project ID, see Obtaining a Project ID.
instance_id
Yes
Specifies the ID of the queried DB instance.
start_date
Yes
Specifies the start date 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.
end_date
Yes
Specifies the end time 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. You can only query slow logs generated within a month.
offset
No
Specifies the page offset, such as 1, 2, 3, or 4. The parameter value is 1 by default if it is not specified.
limit
No
Specifies the number of records on a page. Its value range is from 1 to 100. The parameter value is 10 by default if it is not specified.
type
No
Specifies the statement type. If it is left blank, all statement types are queried. Valid value:
INSERT
UPDATE
SELECT
DELETE
CREATE
Request¶
Response¶
Normal response
¶ Name
Type
Description
slow_log_list
Array of objects
Indicates detailed information.
For details, see Table 3.
total_record
Integer
Indicates the total number of records.
¶ Name
Type
Description
count
String
Indicates the number of executions.
time
String
Indicates the execution time.
lock_time
String
Indicates the lock wait time.
This parameter is not present in the response for PostgreSQL DB engine.
rows_sent
String
Indicates the number of sent rows.
This parameter is not present in the response for PostgreSQL DB engine.
rows_examined
String
Indicates the number of scanned rows.
This parameter is not present in the response for PostgreSQL DB engine.
database
String
Indicates the database which the slow log belongs to.
users
String
Indicates the account.
query_sample
String
Indicates the execution syntax.
type
String
Indicates the statement type.
start_time
String
Indicates the time in the UTC format.
client_ip
String
Indicates the IP address.
Example normal response
{ "total_record": 1, "slow_log_list": [ { "count": "1", "time": "1.04899 s", "lock_time": "0.00003 s", "rows_sent": "0", "rows_examined": "0", "database": "mysql", "users": "root", "query_sample": "INSERT INTO time_zone_name (Name, Time_zone_id) VALUES (N, @time_zone_id);", "type": "INSERT", "start_time": "2018-08-06T10:41:14", "client_ip": "192.*.*.1" } ] }
Abnormal Response
For details, see Abnormal Request Results.
Status Code¶
Normal
200
Abnormal
For details, see Status Codes.
Error Code¶
For details, see Error Codes.