<@U0A71G31CDV> So there are multiple things to cat...
# questions-and-troubleshooting
z
@Rocky So there are multiple things to catch currently running queries: SHOW RUNNIG QUERIES, SHOW PROC '/global_current_queries', SHOW PROC '/current_queries';, SHOW FULL PROCESSLIST; but problem is that some of it has sql text in it, some state (pending running) some resource usage etc. and I cant join them together so may be the best approach is to configure query detail api?
r
You are correct that the various
SHOW
commands provide fragmented information. For example,
SHOW FULL PROCESSLIST
gives the SQL text but lacks granular resource metrics (like bytes scanned or memory usage), while
SHOW PROC '/current_queries'
provides resource metrics but excludes the SQL text. To get a unified view that includes SQL text, state (Running/Pending/Finished), and resource usage, the Query Detail API is indeed the best approach. 1. Configure the Query Detail API To use this API, you must first enable the collection of query details in your FE configuration. * Enable collection: Run the following command (this is a dynamic configuration):
Copy code
sql
    ADMIN SET FRONTEND CONFIG ("enable_collect_query_detail_info" = "true");
* Optional - Persistence: To ensure this persists after a restart, add
enable_collect_query_detail_info = true
to your
fe.conf
. * Optional - Logging: If you want these details written to a local log file (serialized as JSON), you can also set
enable_profile_log = true
. 2. Use the API The Query Detail API returns a JSON array of recent queries (both active and finished) cached in FE memory. * Endpoint:
GET /api/v2/query_detail
* Authentication: Requires HTTP Basic Auth (your StarRocks username and password). * Example Call:
Copy code
bash
    curl -u user:password http://<FE_IP>:<HTTP_PORT>/api/v2/query_detail
Why this is the best approach: This API response includes a
QueryDetail
object for each query containing: * `sql`: Full SQL text. * `state`: Current state (
RUNNING
,
FINISHED
,
FAILED
,
CANCELLED
). *
scanRows
/ `scanBytes`: Real-time data consumption. *
cpuCostNs
/ `memCostBytes`: Resource consumption. * `pendingTime`: Time spent in the queue. * `queryId`: To join with other logs if needed. Alternative for Warehouse users If you are using StarRocks with Warehouses (Cloud-native or v3.2+ with warehouse enabled), you can use the following system table which is joinable via SQL:
Copy code
sql
SELECT * FROM information_schema.warehouse_queries;
This table includes the
QUERY
(SQL text),
STATE
, and
WAREHOUSE_NAME
, though it provides fewer resource metrics than the HTTP API. Summary of Fragmentation Command / Source | SQL Text | Resource Usage (Scan/Mem) | Queue State (Pending)
SHOW FULL PROCESSLIST
| | | (
IsPending
)
SHOW PROC '/current_queries'
| | |
SHOW RUNNING QUERIES
| | | Query Detail API | | | Referencesusing_starrocks/running_queries.mdadministration/management/resource_management/query_queues.mdadministration/management/monitoring/metrics.mdsql-reference/sql-statements/cluster-management/nodes_processes/SHOW_RUNNING_QUERIES.md