From 252643d10069efddcd133aa8a58111227caf6034 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Thu, 10 Aug 2023 12:27:28 +0200 Subject: [PATCH] vmui: change the response for active queries (#4782) * fix: change the response to a valid json (#4676) * vmui/docs: fix response of active queries https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4676 --- app/vmselect/promql/active_queries.go | 7 ++++++- docs/CHANGELOG.md | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/vmselect/promql/active_queries.go b/app/vmselect/promql/active_queries.go index d66058e53..2ef261b49 100644 --- a/app/vmselect/promql/active_queries.go +++ b/app/vmselect/promql/active_queries.go @@ -4,6 +4,7 @@ import ( "fmt" "net/http" "sort" + "strings" "sync" "sync/atomic" "time" @@ -23,8 +24,12 @@ func ActiveQueriesHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, `{"status":"ok","data":[`) for i, aqe := range aqes { d := now.Sub(aqe.startTime) + addr := aqe.quotedRemoteAddr + if n := strings.IndexByte(aqe.quotedRemoteAddr, ','); n != -1 { + addr = aqe.quotedRemoteAddr[:n] + } fmt.Fprintf(w, `{"duration":"%.3fs","id":"%016X","remote_addr":%s,"query":%q,"start":%d,"end":%d,"step":%d}`, - d.Seconds(), aqe.qid, aqe.quotedRemoteAddr, aqe.q, aqe.start, aqe.end, aqe.step) + d.Seconds(), aqe.qid, addr, aqe.q, aqe.start, aqe.end, aqe.step) if i+1 < len(aqes) { fmt.Fprintf(w, `,`) } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ea6aa1d31..1bed6f8f4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -44,6 +44,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly set `vmalert_config_last_reload_successful` value on configuration updates or rollbacks. The bug was introduced in [v1.92.0](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.92.0) in [this PR](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4543). * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): fix `vmalert_remotewrite_send_duration_seconds_total` value, before it didn't count in the real time spending on remote write requests. See [this pr](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4801) for details. * BUGFIX: [vmbackupmanager](https://docs.victoriametrics.com/vmbackupmanager.html): fix panic when creating a backup to a local filesystem on Windows. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/4704). +* BUGFIX: [vmui](https://docs.victoriametrics.com/#vmui): fix the response of active queries to valid JSON. See [this pull request](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4782). ## [v1.92.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.92.1)