Query Profile Action
Requestβ
GET /rest/v2/manager/query/query_info
GET /rest/v2/manager/query/trace/{trace_id}
GET /rest/v2/manager/query/sql/{query_id}
GET /rest/v2/manager/query/profile/text/{query_id}
GET /rest/v2/manager/query/profile/graph/{query_id}
GET /rest/v2/manager/query/profile/json/{query_id}
GET /rest/v2/manager/query/profile/fragments/{query_id}
GET /rest/v2/manager/query/current_queries
GET /rest/v2/manager/query/kill/{query_id}
Get the query informationβ
GET /rest/v2/manager/query/query_info
Descriptionβ
Gets information about select queries for all fe nodes in the cluster.
Query parametersβ
-
query_id
Optional, specifies the query ID of the query to be returned, default returns information for all queries.
-
search
Optional, specifies that query information containing strings is returned, currently only string matches are performed.
-
is_all_node
Optional, if true, returns query information for all fe nodes, if false, returns query information for the current fe node. The default is true.
Responseβ
{
"msg": "success",
"code": 0,
"data": {
"column_names": [
"Query ID",
"FE Node",
"Query User",
"Execution Database",
"Sql",
"Query Type",
"Start Time",
"End Time",
"Execution Duration",
"Status"
],
"rows": [
[
...
]
]
},
"count": 0
}
Since Doris Version 1.2, Admin and Root users can view all queries. Regular users can only view their own submitted queries.
Examplesβ
GET /rest/v2/manager/query/query_info
{
"msg": "success",
"code": 0,
"data": {
"column_names": [
"Query ID",
"FE Node",
"Query User",
"Execution Database",
"Sql",
"Query Type",
"Start Time",
"End Time",
"Execution Duration",
"Status"
],
"rows": [
[
"d7c93d9275334c35-9e6ac5f295a7134b",
"127.0.0.1:8030",
"root",
"default_cluster:testdb",
"select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id",
"Query",
"2021-07-29 16:59:12",
"2021-07-29 16:59:12",
"109ms",
"EOF"
]
]
},
"count": 0
}
Get Query Id By Trace Idβ
GET /rest/v2/manager/query/trace_id/{trace_id}
Descriptionβ
Get query id by trance id.
Before executing a Query, set a unique trace id:
set session_context="trace_id:your_trace_id";
After executing the Query within the same Session, the query id can be obtained through the trace id.
Path parametersβ
-
{trace_id}
User specific trace id.
Query parametersβ
Responseβ
{
"msg": "success",
"code": 0,
"data": "fb1d9737de914af1-a498d5c5dec638d3",
"count": 0
}
Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:
{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
Get the sql and text profile for the specified queryβ
GET /rest/v2/manager/query/sql/{query_id}
GET /rest/v2/manager/query/profile/text/{query_id}
Descriptionβ
Get the sql and profile text for the specified query id.
Path parametersβ
-
query_id
The query id.
Query parametersβ
-
is_all_node
Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.
Responseβ
{
"msg": "success",
"code": 0,
"data": {
"sql": ""
},
"count": 0
}
{
"msg": "success",
"code": 0,
"data": {
"profile": ""
},
"count": 0
}
Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:
{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
Examplesβ
-
get sql.
GET /rest/v2/manager/query/sql/d7c93d9275334c35-9e6ac5f295a7134b
Response:
{
"msg": "success",
"code": 0,
"data": {
"sql": "select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id"
},
"count": 0
}
Get the specified query fragment and instance informationβ
GET /rest/v2/manager/query/profile/fragments/{query_id}
Descriptionβ
Get the fragment name, instance id and execution time for the specified query id.
Path parametersβ
-
query_id
The query id.
Query parametersβ
-
is_all_node
Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.
Responseβ
{
"msg": "success",
"code": 0,
"data": [
{
"fragment_id": "",
"time": "",
"instance_id": {
"": ""
}
}
],
"count": 0
}
Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:
{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
Examplesβ
```
GET /rest/v2/manager/query/profile/fragments/d7c93d9275334c35-9e6ac5f295a7134b
Response:
{
"msg": "success",
"code": 0,
"data": [
{
"fragment_id": "0",
"time": "36.169ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134e": "36.169ms"
}
},
{
"fragment_id": "1",
"time": "20.710ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134c": "20.710ms"
}
},
{
"fragment_id": "2",
"time": "7.83ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134d": "7.83ms"
}
}
],
"count": 0
}
```
Get the specified query id tree profile informationβ
GET /rest/v2/manager/query/profile/graph/{query_id}
Descriptionβ
Get the tree profile information of the specified query id, same as show query profile
command.
Path parametersβ
-
query_id
The query id.
Query parametersβ
-
fragment_id
andinstance_id
Optional, both parameters must be specified or not.
If both are not specified, a simple tree of profiles is returned, equivalent toshow query profile '/query_id'
;
If both are specified, a detailed profile tree is returned, which is equivalent toshow query profile '/query_id/fragment_id/instance_id'
. -
is_all_node
Optional, if true then query information about the specified query id in all fe nodes, if false then query information about the specified query id in the currently connected fe nodes. The default is true.
Responseβ
{
"msg": "success",
"code": 0,
"data": {
"graph":""
},
"count": 0
}
Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:
{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
Current running queriesβ
GET /rest/v2/manager/query/current_queries
Descriptionβ
Same as show proc "/current_query_stmts"
, return current running queries.
Path parametersβ
Query parametersβ
-
is_all_node
Optional. Return current running queries from all FE if set to true. Default is true.
Responseβ
{
"msg": "success",
"code": 0,
"data": {
"columnNames": ["Frontend", "QueryId", "ConnectionId", "Database", "User", "ExecTime", "SqlHash", "Statement"],
"rows": [
["172.19.0.3", "108e47ab438a4560-ab1651d16c036491", "2", "", "root", "6074", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"],
["172.19.0.11", "3606cad4e34b49c6-867bf6862cacc645", "3", "", "root", "9306", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"]
]
},
"count": 0
}
Cancel queryβ
POST /rest/v2/manager/query/kill/{query_id}
Descriptionβ
Cancel query of specified connection.
Path parametersβ
-
{query_id}
query id. You can get query id by
trance_id
api.
Query parametersβ
Responseβ
{
"msg": "success",
"code": 0,
"data": null,
"count": 0
}