From 2c5e1cd893487196a77a7a05c2b96ae24f8f24bf Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 8 Jul 2021 13:13:01 +0300 Subject: [PATCH] app/vmselect: move web ui from /ui to /select//prometheus/ui This way the UI is available for every tenant (aka accountID) and the UI can automatically determine the needed per-tenant datasource path from page referer. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1413 --- app/vmselect/main.go | 12 ++++++------ docs/CHANGELOG.md | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/vmselect/main.go b/app/vmselect/main.go index 4ae8225ecd..daecd070b6 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -142,15 +142,9 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { } fmt.Fprintf(w, `vmselect - a component of VictoriaMetrics cluster
docs
-Web UI
`) return true } - // ui access. - if strings.HasPrefix(r.URL.Path, "/ui") { - uiFileServer.ServeHTTP(w, r) - return true - } startTime := time.Now() defer requestDuration.UpdateDuration(startTime) @@ -246,6 +240,12 @@ func selectHandler(startTime time.Time, w http.ResponseWriter, r *http.Request, httpRequests.Get(at).Inc() httpRequestsDuration.Get(at).Add(int(time.Since(startTime).Milliseconds())) }() + if strings.HasPrefix(p.Suffix, "prometheus/ui") { + // ui access. + prefix := strings.Join([]string{"", p.Prefix, p.AuthToken, "prometheus"}, "/") + http.StripPrefix(prefix, uiFileServer).ServeHTTP(w, r) + return true + } if strings.HasPrefix(p.Suffix, "prometheus/api/v1/label/") { s := p.Suffix[len("prometheus/api/v1/label/"):] if strings.HasSuffix(s, "/values") { diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index ee76786fe4..87e7649cbe 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,7 +10,9 @@ sort: 15 * FEATURE: reduce memory usage by up to 30% on production workloads. * FEATURE: log http request path plus all the query args on errors during request processing. Previously only http request path was logged without query args, so it could be hard debugging such errors. * FEATURE: export `vmselect_request_duration_seconds` and `vminsert_request_duration_seconds` [VictoriaMetrics histograms](https://valyala.medium.com/improving-histogram-usability-for-prometheus-and-grafana-bc7e5df0e350) at `/metrics` page. These histograms can be used for determining latency distribution for the served requests. -* FEATURE: vmselect: embed [vmui](https://github.com/VictoriaMetrics/vmui) into a single-node VictoriaMetrics and into `vmselect` component of cluster version. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1413). The web interface is available at `/ui` page. +* FEATURE: vmselect: embed [vmui](https://github.com/VictoriaMetrics/vmui) into a single-node VictoriaMetrics and into `vmselect` component of cluster version. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1413). The web interface is available at the following paths: + * `/ui/` for a single-node VictoriaMetrics + * `/select//prometheus/ui/` for `vmselect` at cluster version of VictoriaMetrics * BUGFIX: vmagent: remove `{ %space %}` typo in `/targets` output. The typo has been introduced in v1.62.0. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1408). * BUGFIX: vmagent: fix CSS styles on `/targets` page. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1422).