diff --git a/README.md b/README.md index 450a72936..df089f4e9 100644 --- a/README.md +++ b/README.md @@ -316,6 +316,7 @@ The UI allows exploring query results via graphs and tables. It also provides th - [Metrics explorer](#metrics-explorer) - automatically builds graphs for selected metrics; - [Cardinality explorer](#cardinality-explorer) - stats about existing metrics in TSDB; - [Top queries](#top-queries) - shows most frequently executed queries; + - [Active queries](#active-queries) - shows currently executed queries; - Tools: - [Trace analyzer](#query-tracing) - playground for loading query traces in JSON format; - [WITH expressions playground](https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus/graph/#/expand-with-exprs) - test how WITH expressions work; @@ -360,6 +361,15 @@ See the [example VMUI at VictoriaMetrics playground](https://play.victoriametric * queries with the biggest average execution duration; * queries that took the most summary time for execution. +## Active queries + +[VMUI](#vmui) provides `active queries` tab, which shows currently execute queries. +It provides the following information per each query: + +- The query itself, together with the time range and step args passed to [/api/v1/query_range](https://docs.victoriametrics.com/keyConcepts.html#range-query). +- The duration of the query execution. +- The client address, who initiated the query execution. + ## Metrics explorer [VMUI](#vmui) provides an ability to explore metrics exported by a particular `job` / `instance` in the following way: diff --git a/app/vmselect/main.go b/app/vmselect/main.go index c0d34cdc0..2b3fc74c7 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -329,8 +329,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { case "/api/v1/status/active_queries": statusActiveQueriesRequests.Inc() httpserver.EnableCORS(w, r) - w.Header().Set("Content-Type", "application/json") - promql.WriteActiveQueries(w) + promql.WriteActiveQueries(w, r) return true case "/api/v1/status/top_queries": topQueriesRequests.Inc() diff --git a/app/vmselect/promql/active_queries.go b/app/vmselect/promql/active_queries.go index 4616c42e9..8e0e22eb9 100644 --- a/app/vmselect/promql/active_queries.go +++ b/app/vmselect/promql/active_queries.go @@ -2,7 +2,7 @@ package promql import ( "fmt" - "io" + "net/http" "sort" "sync" "sync/atomic" @@ -12,8 +12,10 @@ import ( // WriteActiveQueries writes active queries to w. // // The written active queries are sorted in descending order of their exeuction duration. -func WriteActiveQueries(w io.Writer) { +func WriteActiveQueries(w http.ResponseWriter, r *http.Request) { aqes := activeQueriesV.GetAll() + + w.Header().Set("Content-Type", "application/json") sort.Slice(aqes, func(i, j int) bool { return aqes[i].startTime.Sub(aqes[j].startTime) < 0 }) diff --git a/docs/README.md b/docs/README.md index 62807d4f5..e03318e8b 100644 --- a/docs/README.md +++ b/docs/README.md @@ -319,6 +319,7 @@ The UI allows exploring query results via graphs and tables. It also provides th - [Metrics explorer](#metrics-explorer) - automatically builds graphs for selected metrics; - [Cardinality explorer](#cardinality-explorer) - stats about existing metrics in TSDB; - [Top queries](#top-queries) - shows most frequently executed queries; + - [Active queries](#active-queries) - shows currently executed queries; - Tools: - [Trace analyzer](#query-tracing) - playground for loading query traces in JSON format; - [WITH expressions playground](https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus/graph/#/expand-with-exprs) - test how WITH expressions work; @@ -363,6 +364,15 @@ See the [example VMUI at VictoriaMetrics playground](https://play.victoriametric * queries with the biggest average execution duration; * queries that took the most summary time for execution. +## Active queries + +[VMUI](#vmui) provides `active queries` tab, which shows currently execute queries. +It provides the following information per each query: + +- The query itself, together with the time range and step args passed to [/api/v1/query_range](https://docs.victoriametrics.com/keyConcepts.html#range-query). +- The duration of the query execution. +- The client address, who initiated the query execution. + ## Metrics explorer [VMUI](#vmui) provides an ability to explore metrics exported by a particular `job` / `instance` in the following way: diff --git a/docs/Single-server-VictoriaMetrics.md b/docs/Single-server-VictoriaMetrics.md index 3b7be3538..faac96326 100644 --- a/docs/Single-server-VictoriaMetrics.md +++ b/docs/Single-server-VictoriaMetrics.md @@ -327,6 +327,7 @@ The UI allows exploring query results via graphs and tables. It also provides th - [Metrics explorer](#metrics-explorer) - automatically builds graphs for selected metrics; - [Cardinality explorer](#cardinality-explorer) - stats about existing metrics in TSDB; - [Top queries](#top-queries) - shows most frequently executed queries; + - [Active queries](#active-queries) - shows currently executed queries; - Tools: - [Trace analyzer](#query-tracing) - playground for loading query traces in JSON format; - [WITH expressions playground](https://play.victoriametrics.com/select/accounting/1/6a716b0f-38bc-4856-90ce-448fd713e3fe/prometheus/graph/#/expand-with-exprs) - test how WITH expressions work; @@ -371,6 +372,15 @@ See the [example VMUI at VictoriaMetrics playground](https://play.victoriametric * queries with the biggest average execution duration; * queries that took the most summary time for execution. +## Active queries + +[VMUI](#vmui) provides `active queries` tab, which shows currently execute queries. +It provides the following information per each query: + +- The query itself, together with the time range and step args passed to [/api/v1/query_range](https://docs.victoriametrics.com/keyConcepts.html#range-query). +- The duration of the query execution. +- The client address, who initiated the query execution. + ## Metrics explorer [VMUI](#vmui) provides an ability to explore metrics exported by a particular `job` / `instance` in the following way: