Exporting Slow Query Logs
Function
After Slow Query Log is enabled, you can export the slow query logs within a specified period at a time. The data can be obtained by page. This function is available only for paid instances.
URI
GET /v3/{project_id}/instances/{instance_id}/slow-query-logs
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
project_id |
Yes |
String |
Project ID. To obtain this value, see Obtaining a Project ID. |
instance_id |
Yes |
String |
Instance ID. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
datastore_type |
Yes |
String |
Database type, which can be MySQL, TaurusDB, and PostgreSQL |
start_at |
Yes |
Long |
Start time in Unix timestamp format, in milliseconds. |
end_at |
Yes |
Long |
End time in Unix timestamp format, in milliseconds. |
limit |
Yes |
Integer |
Number of records on each page. The maximum value is 2,000. |
marker |
No |
String |
Query result marker. When the first page is obtained, no value needs to be assigned to this parameter. When the next page is obtained, the returned value of the first page query result is used. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
X-Auth-Token |
Yes |
String |
User token. |
X-Language |
No |
String |
Request language type. Enumerated values:
|
Response Parameters
Status code: 200
Parameter |
Type |
Description |
---|---|---|
slow_logs |
Array of slow log objects |
Slow SQL set. If the set is empty, all slow SQL statements have been exported. |
next_marker |
String |
Identifier required for obtaining the next page. This parameter is valid only within 3 minutes. |
Parameter |
Type |
Description |
---|---|---|
sql |
String |
SQL statement. |
database |
String |
Database name. |
client |
String |
Client. |
user |
String |
User. |
execute_at |
Long |
Execution start time in Unix timestamp format, in milliseconds. |
query_time |
Double |
Duration (s). |
lock_time |
Double |
Lock wait time (s). |
rows_examined |
Long |
Scanned rows. |
rows_sent |
Long |
Returned rows. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum length: 8 characters Maximum length: 36 characters |
error_msg |
String |
Error message. Minimum length: 2 characters Maximum length: 512 characters |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. Minimum length: 8 characters Maximum length: 36 characters |
error_msg |
String |
Error message. Minimum length: 2 characters Maximum length: 512 characters |
Example Request
Exporting slow query logs
GET https://das.cn-north-1.myhuaweicloud.com/v3/054e292c9880d4992f02c0196d3ea468/instances/da304cd5bbb944de828759bc7be3d3fein01/slow-query-logs?start_at=1611975464337&end_at=1611979064337&limit=10&marker=DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAQH8YWSEFfM3FyOXZRNzJQOTVLNHNBOTQ2UQ==&datastore_type=MySQL
Example Response
Status code: 200
Response body for exporting slow query logs
{ "slow_logs" : [ { "execute_at" : 1612343898000, "sql" : "SELECT sleep(10)\nLIMIT 0, 50;", "database" : "123", "client" : "[100.79.0.248]", "user" : "root[root]", "query_time" : 10.000158309936523, "lock_time" : 0, "rows_examined" : 0, "rows_sent" : 1 } ], "next_marker" : "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAJr48WZERxYkx5Q2VRQS1LSXRrRWt0VEN1QQ==" }
Status Codes
Status Code |
Description |
---|---|
200 |
Response body for exporting slow query logs. |
400 |
Client error. |
500 |
Server error. |
Error Codes
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