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 /rest/v2/manager/query/statistics/{trace_id} (4.0.0+)
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_idOptional, specifies the query ID of the query to be returned, default returns information for all queries.
-
searchOptional, specifies that query information containing strings is returned, currently only string matches are performed.
-
is_all_nodeOptional, 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
}
Since Doris version 1.2, 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_idThe query id.
Query parameters
-
is_all_nodeOptional, 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
}
Since Doris version 1.2, 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}
Since 2.1.1, this API is deprecated. You can still download profile from http://<fe_ip>:<fe_http_port>/QueryProfile
Description
Get the fragment name, instance id, host ip/port and execution time for the specified query id.
Path parameters
-
query_idThe query id.
Query parameters
-
is_all_nodeOptional, 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": {
"": {
"host": "",
"active_time": ""
}
}
}
],
"count": 0
}
Since Doris version 1.2, 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": {
"host": "172.19.0.4:9060",
"active_time": "36.169ms"
}
}
},
{
"fragment_id": "1",
"time": "20.710ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134c": {
"host": "172.19.0.5:9060",
"active_time": "20.710ms"
}
}
},
{
"fragment_id": "2",
"time": "7.83ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134d": {
"host": "172.19.0.6:9060",
"active_time": "7.83ms"
},
"d7c93d9275334c35-9e6ac5f295a7134f": {
"host": "172.19.0.7:9060",
"active_time": "10.873ms"
}
}
}
],
"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_idThe query id.
Query parameters
-
fragment_idandinstance_idOptional, 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_nodeOptional, 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
}
Since Doris version 1.2, 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
Return current running queries with runtime statistics. This endpoint shares the same statistics view as SHOW PROC "/current_queries" and SHOW PROC "/current_query_stmts", providing task-level progress and resource metrics (scan/cpu/memory/shuffle/spill/cache). Version 4.1.1+.
Path parameters
Query parameters
-
is_all_nodeOptional. Return current running queries from all FE if set to true. Default is true.
Response
{
"msg": "success",
"code": 0,
"data": {
"columnNames": [
"Frontend", "QueryId", "ConnectionId", "Catalog", "Database",
"User", "ExecTime", "SqlHash", "Statement",
"ScanRows", "ScanBytes", "ProcessRows", "CpuMs",
"MaxPeakMemoryBytes", "CurrentUsedMemoryBytes", "WorkloadGroupId",
"ShuffleSendBytes", "ShuffleSendRows",
"ScanBytesFromLocalStorage", "ScanBytesFromRemoteStorage",
"SpillWriteBytesToLocalStorage", "SpillReadBytesFromLocalStorage",
"BytesWriteIntoCache",
"TotalTasks", "FinishedTasks", "Progress"
],
"rows": [
[
"172.19.0.3", "108e47ab438a4560-ab1651d16c036491", "2", "internal",
"testdb", "root", "6074",
"1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)",
"0", "0.00", "0", "0",
"0.00", "0.00", "0",
"0.00", "0",
"0.00", "0.00",
"0.00", "0.00",
"0.00",
"1", "1", "100%"
]
]
},
"count": 0
}
| Column | Description |
|---|---|
| Frontend | The FE node handling the query |
| QueryId | Unique query identifier |
| ConnectionId | MySQL connection ID |
| Catalog | Catalog name |
| Database | Schema/Database name |
| User | User who submitted the query |
| ExecTime | Execution time in milliseconds |
| SqlHash | MD5 hash of the SQL statement |
| Statement | SQL statement text |
| ScanRows | Total rows scanned from storage |
| ScanBytes | Total bytes scanned from storage |
| ProcessRows | Rows processed through the execution pipeline |
| CpuMs | CPU time consumed in milliseconds |
| MaxPeakMemoryBytes | Maximum memory peak during execution |
| CurrentUsedMemoryBytes | Current memory used by the query |
| WorkloadGroupId | ID of the workload group |
| ShuffleSendBytes | Total bytes sent via shuffle |
| ShuffleSendRows | Total rows sent via shuffle |
| ScanBytesFromLocalStorage | Bytes scanned from local storage |
| ScanBytesFromRemoteStorage | Bytes scanned from remote storage (e.g., HDFS, S3) |
| SpillWriteBytesToLocalStorage | Bytes spilled to local disk |
| SpillReadBytesFromLocalStorage | Bytes read back from local spill disk |
| BytesWriteIntoCache | Bytes written into cache |
| TotalTasks | Total number of pipeline tasks for this query |
| FinishedTasks | Number of completed pipeline tasks |
| Progress | Computed query progress (FinishedTasks / TotalTasks) |
## 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
```json
{
"msg": "success",
"code": 0,
"data": null,
"count": 0
}
Get Query Progress by Trace ID
GET /rest/v2/manager/query/statistics/{trace_id} (4.0.0+)
Description
Retrieve the statistics of a currently running query by Trace ID. You can call this API periodically to obtain the progress of the query.
Path parameters
-
{trace_id}Trace ID. The user-defined Trace ID set via
SET session_context="trace_id:xxxx".
Response
{
"msg": "success",
"code": 0,
"data": {
"scanRows": 1234567,
"scanBytes": 987654321,
"returnedRows": 12345,
"processRows": 2345678,
"cpuMs": 15600,
"maxPeakMemoryBytes": 536870912,
"currentUsedMemoryBytes": 268435456,
"shuffleSendBytes": 104857600,
"shuffleSendRows": 50000,
"scanBytesFromLocalStorage": 734003200,
"scanBytesFromRemoteStorage": 253651121,
"spillWriteBytesToLocalStorage": 0,
"spillReadBytesFromLocalStorage": 0,
"bytesWriteIntoCache": 0,
"totalTasksNum": 74,
"finishedTasksNum": 51,
"progress": "68%"
},
"count": 0
}