Querying Database Slow Query Logs
Function
This API is used to query the latest 2000 database slow query logs.
Constraints
- This API supports GaussDB(for Cassandra) instances.
- This API can be used to query only the latest 2000 slow query logs in a specified time range.
URI
- URI format
GET /v3/{project_id}/instances/{instance_id}/slowlog?start_date={start_date}&end_date={end_date}
- Parameter description
Table 1 Parameter description Name
Mandatory
Description
project_id
Yes
Specifies the project ID of a tenant in a region.
instance_id
Yes
Specifies the DB instance ID.
start_date
Yes
Specifies the start 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. For example, in the Beijing time zone, the time zone offset is shown as +0800.
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. For example, in the Beijing time zone, the time zone offset is shown as +0800. Only slow query logs generated within the last month can be queried.
offset
No
Specifies the index position. Its value range is [0, 1999].
If offset is set to N, the resource query starts from the N+1 piece of data. The value is 0 by default, indicating that the query starts from the first piece of data. The value must be a positive number.
limit
No
Specifies the number of resources to be queried. The value ranges from 1 (inclusive) to 100 (inclusive).
The sum of values of limit and offset must be less than or equal to 2000.
node_id
No
Specifies the node ID. If this parameter is left blank, all nodes of the instance are queried.
For details about the value, see "id" in table Table 8 in Querying DB Instances.
type
No
Specifies the statement type. If this parameter is left empty, all statement types are queried. You can also specify the following log type:
- SELECT
Requests
- Request header Query database slow query logs.
GEThttps://GaussDB_NoSQL_Endpoint/v3/0483b6b16e954cb88930a360d2c4e663/instances/6ade8143870047b8999aba8f1891b48ein06/slowlog?start_date=2018-08-06T10:41:14+0800&end_date=2018-08-07T10:41:14+0800
Query database slow query logs based on specified conditions.GEThttps://GaussDB_NoSQL_Endpoint/v3/0549b4a43100d4f32f51c01c2fe4acdb/instances/6ade8143870047b8999aba8f1891b48ein06/slowlog?type=SELECT&offset=1&limit=20&node_id=a7c84462483642798cf159237343135fno06&start_date=2018-08-06T10:41:14+0800&end_date=2018-08-07T10:41:14+0800
Responses
- Normal responses
Table 2 Parameter description 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.
Table 3 slow_log_list field data structure description Name
Type
Description
time
String
Indicates the execution time.
database
String
Indicates the database which the slow log belongs to.
query_sample
String
Indicates the syntax.
type
String
Indicates the statement type.
start_time
String
Indicates the time in the UTC format.
- Example normal response
{ "total_record": 1, "slow_log_list": [ { "time": "513 ms", "database": "cassandra", "query_sample": "SELECT * FROM cassandra.sz_user_hw LIMIT 100;", "type": "SELECT", "start_time": "2020-02-12T09:55:12.065000Z", } ] }
Status Code
For more information, see Status Code.
Error Code
For more information, see Error Code.
Last Article: Log Management
Next Article: Permissions Policies and Supported Actions
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.