app/vmselect: expose vmui at /select/<accountID>/prometheus/vmui additionally to /select/<accountID>/vmui

The /select/<accountID>/prometheus/vmui is needed for accessing via server-side Prometheus datasource for Grafana.

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/1413
This commit is contained in:
Aliaksandr Valialkin 2021-07-10 12:52:13 +03:00
parent 0b98f6c7ff
commit ddaa12050d

View File

@ -239,9 +239,14 @@ 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, "vmui") {
// Expose vmui at /select/<accountID>/vmui and at /select/<accountID>/prometheus/vmui .
// The /select/<accountID>/prometheus/vmui is needed for server-side Prometheus datasource in Grafana.
if strings.HasPrefix(p.Suffix, "vmui") || strings.HasPrefix(p.Suffix, "prometheus/vmui") {
// vmui access.
prefix := strings.Join([]string{"", p.Prefix, p.AuthToken}, "/")
if strings.HasPrefix(p.Suffix, "prometheus/") {
prefix += "/prometheus"
}
http.StripPrefix(prefix, vmuiFileServer).ServeHTTP(w, r)
return true
}