diff --git a/app/victoria-logs/main.go b/app/victoria-logs/main.go index 8ba6bb34e..5cf3add9a 100644 --- a/app/victoria-logs/main.go +++ b/app/victoria-logs/main.go @@ -78,7 +78,7 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool { fmt.Fprintf(w, "See docs at https://docs.victoriametrics.com/VictoriaLogs/
") fmt.Fprintf(w, "Useful endpoints:
") httpserver.WriteAPIHelp(w, [][2]string{ - {"vmui", "Web UI for VictoriaLogs"}, + {"select/vmui", "Web UI for VictoriaLogs"}, {"metrics", "available service metrics"}, {"flags", "command-line flags"}, }) diff --git a/app/vlinsert/main.go b/app/vlinsert/main.go index 7aa7254a1..6e253af58 100644 --- a/app/vlinsert/main.go +++ b/app/vlinsert/main.go @@ -20,6 +20,7 @@ func Stop() { func RequestHandler(w http.ResponseWriter, r *http.Request) bool { path := r.URL.Path if !strings.HasPrefix(path, "/insert/") { + // Skip requests, which do not start with /insert/, since these aren't our requests. return false } path = strings.TrimPrefix(path, "/insert") diff --git a/app/vlselect/main.go b/app/vlselect/main.go index 3b29b8977..844437c04 100644 --- a/app/vlselect/main.go +++ b/app/vlselect/main.go @@ -71,10 +71,29 @@ var vmuiFileServer = http.FileServer(http.FS(vmuiFiles)) // RequestHandler handles select requests for VictoriaLogs func RequestHandler(w http.ResponseWriter, r *http.Request) bool { path := r.URL.Path + if !strings.HasPrefix(path, "/select/") { + // Skip requests, which do not start with /select/, since these aren't our requests. + return false + } path = strings.TrimPrefix(path, "/select") path = strings.ReplaceAll(path, "//", "/") - // Limit the number of concurrent queries. + if path == "/vmui" { + // VMUI access via incomplete url without `/` in the end. Redirect to complete url. + // Use relative redirect, since the hostname and path prefix may be incorrect if VictoriaMetrics + // is hidden behind vmauth or similar proxy. + _ = r.ParseForm() + newURL := "vmui/?" + r.Form.Encode() + httpserver.Redirect(w, newURL) + return true + } + if strings.HasPrefix(path, "/vmui/") { + r.URL.Path = path + vmuiFileServer.ServeHTTP(w, r) + return true + } + + // Limit the number of concurrent queries, which can consume big amounts of CPU. startTime := time.Now() stopCh := r.Context().Done() select { @@ -115,24 +134,11 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { } switch { - case path == "/vmui": - // VMUI access via incomplete url without `/` in the end. Redirect to complete url. - // Use relative redirect, since, since the hostname and path prefix may be incorrect if VictoriaMetrics - // is hidden behind vmauth or similar proxy. - _ = r.ParseForm() - path = strings.TrimPrefix(path, "/") - newURL := path + "/?" + r.Form.Encode() - httpserver.Redirect(w, newURL) - return true case path == "/logsql/query": logsqlQueryRequests.Inc() httpserver.EnableCORS(w, r) logsql.ProcessQueryRequest(w, r, stopCh) return true - case strings.HasPrefix(path, "/vmui/"): - r.URL.Path = path - vmuiFileServer.ServeHTTP(w, r) - return true default: return false } diff --git a/app/vmselect/main.go b/app/vmselect/main.go index baf798e9a..e1100da91 100644 --- a/app/vmselect/main.go +++ b/app/vmselect/main.go @@ -175,7 +175,7 @@ func RequestHandler(w http.ResponseWriter, r *http.Request) bool { switch { case path == "/vmui" || path == "/graph": // VMUI access via incomplete url without `/` in the end. Redirect to complete url. - // Use relative redirect, since, since the hostname and path prefix may be incorrect if VictoriaMetrics + // Use relative redirect, since the hostname and path prefix may be incorrect if VictoriaMetrics // is hidden behind vmauth or similar proxy. _ = r.ParseForm() path = strings.TrimPrefix(path, "/") diff --git a/docs/VictoriaLogs/querying/README.md b/docs/VictoriaLogs/querying/README.md index 75c77ab6d..de969af84 100644 --- a/docs/VictoriaLogs/querying/README.md +++ b/docs/VictoriaLogs/querying/README.md @@ -60,7 +60,7 @@ with `vl_http_requests_total{path="/select/logsql/query"}` metric. ## Web UI VictoriaLogs provides a simple Web UI for logs [querying](https://docs.victoriametrics.com/VictoriaLogs/LogsQL.html) and exploration -at `http://localhost:9428/vmui`. The UI allows exploring query results: +at `http://localhost:9428/select/vmui`. The UI allows exploring query results: