跳到主要内容
版本:Stable-3.5

Query detail API

Query detail API 用于查询 FE 内存中缓存的查询执行详情。

备注

仅当 FE 配置项 enable_collect_query_detail_infotrue 时,系统才会收集并返回 Query detail 记录。

接口

  • GET /api/query_detail (v1)
  • GET /api/v2/query_detail (v2,支持 is_request_all_frontend,返回封装结构)

请求参数

参数名是否必选默认值说明
event_time-下界过滤条件,仅返回 eventTime 大于该值的记录。传入 0 表示返回所有缓存记录。
user-user 字段过滤,大小写不敏感。
is_request_all_frontend否(仅 v2)falsetrue 时,当前 FE 会向其他存活的 FE 查询并合并结果。

响应

  • v1 返回 QueryDetail 数组。
  • v2 返回 { "code": "0", "message": "OK", "result": [ ... ] },其中 resultQueryDetail 列表。

认证与权限

该 API 需要使用 HTTP Basic 认证

接口不会进行额外的权限校验,只要登录成功即可访问。任何已认证用户都可以查看所有缓存的查询详情;如果指定了 user 参数,则只返回对应用户的记录。

QueryDetail 字段说明

字段名类型说明
queryIdstring查询 ID。
eventTimelong用于过滤的内部时间戳,由系统时间生成的单调递增纳秒时间戳。
isQueryboolean是否为查询语句。
remoteIPstring客户端 IP 地址,或 System
connIdint连接 ID。
startTimelong查询开始时间(毫秒,Unix 时间戳)。
endTimelong查询结束时间(毫秒,Unix 时间戳);未完成时为 -1
latencylong查询延迟(毫秒);未完成时为 -1
pendingTimelongPending 阶段耗时(毫秒)。
netTimelong净执行时间(毫秒)。
netComputeTimelong净计算时间(毫秒)。
statestring查询状态:RUNNINGFINISHEDFAILEDCANCELLED
databasestring当前数据库。
sqlstringSQL 语句文本(可能根据配置进行脱敏)。
userstring登录用户(全限定用户名)。
impersonatedUserstringEXECUTE AS 的目标用户;未使用时为 null
errorMessagestring查询失败时的错误信息。
explainstringExplain 执行计划(级别由 query_detail_explain_level 控制)。
profilestring若收集则返回 Profile 信息。
resourceGroupNamestring资源组名称。
scanRowslong扫描的行数。
scanByteslong扫描的数据量(字节)。
returnRowslong返回的行数。
cpuCostNslongCPU 消耗时间(纳秒)。
memCostByteslong内存消耗(字节)。
spillByteslong落盘数据量(字节)。
cacheMissRatiofloat缓存未命中率(百分比,0–100)。
warehousestringWarehouse 名称。
digeststringSQL Digest。
catalogstringCatalog 名称。
commandstringMySQL 命令名称。
preparedStmtIdstring预编译语句 ID。
queryFeMemorylong查询在 FE 上分配的内存(字节)。
querySourcestring查询来源:EXTERNALINTERNALMVTASK

示例

v1

curl -u root: "http://<fe_host>:<fe_http_port>/api/query_detail?event_time=0"

v2

curl -u root: "http://<fe_host>:<fe_http_port>/api/v2/query_detail?event_time=0&is_request_all_frontend=true"
Rocky the happy otterStarRocks Assistant

AI generated answers are based on docs and other sources. Please test answers in non-production environments.