mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Redirect /graph to /query in new UI, preserving params
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
8ee70c5fa0
commit
d0ee5427bd
37
web/web.go
37
web/web.go
|
@ -63,8 +63,9 @@ import (
|
||||||
"github.com/prometheus/prometheus/web/ui"
|
"github.com/prometheus/prometheus/web/ui"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Paths that are handled by the React / Reach router that should all be served the main React app's index.html.
|
// Paths handled by the React router that should all serve the main React app's index.html,
|
||||||
var reactRouterPaths = []string{
|
// no matter if agent mode is enabled or not.
|
||||||
|
var oldUIReactRouterPaths = []string{
|
||||||
"/config",
|
"/config",
|
||||||
"/flags",
|
"/flags",
|
||||||
"/service-discovery",
|
"/service-discovery",
|
||||||
|
@ -72,16 +73,31 @@ var reactRouterPaths = []string{
|
||||||
"/targets",
|
"/targets",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var newUIReactRouterPaths = []string{
|
||||||
|
"/config",
|
||||||
|
"/flags",
|
||||||
|
"/service-discovery",
|
||||||
|
"/alertmanager-discovery",
|
||||||
|
"/status",
|
||||||
|
"/targets",
|
||||||
|
}
|
||||||
|
|
||||||
// Paths that are handled by the React router when the Agent mode is set.
|
// Paths that are handled by the React router when the Agent mode is set.
|
||||||
var reactRouterAgentPaths = []string{
|
var reactRouterAgentPaths = []string{
|
||||||
"/agent",
|
"/agent",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Paths that are handled by the React router when the Agent mode is not set.
|
// Paths that are handled by the React router when the Agent mode is not set.
|
||||||
var reactRouterServerPaths = []string{
|
var oldUIReactRouterServerPaths = []string{
|
||||||
"/alerts",
|
"/alerts",
|
||||||
"/graph",
|
"/graph",
|
||||||
"/query",
|
"/rules",
|
||||||
|
"/tsdb-status",
|
||||||
|
}
|
||||||
|
|
||||||
|
var newUIReactRouterServerPaths = []string{
|
||||||
|
"/alerts",
|
||||||
|
"/query", // The old /graph redirects to /query on the server side.
|
||||||
"/rules",
|
"/rules",
|
||||||
"/tsdb-status",
|
"/tsdb-status",
|
||||||
}
|
}
|
||||||
|
@ -382,6 +398,12 @@ func New(logger log.Logger, o *Options) *Handler {
|
||||||
http.Redirect(w, r, path.Join(o.ExternalURL.Path, homePage), http.StatusFound)
|
http.Redirect(w, r, path.Join(o.ExternalURL.Path, homePage), http.StatusFound)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if o.UseNewUI {
|
||||||
|
router.Get("/graph", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
http.Redirect(w, r, path.Join(o.ExternalURL.Path, "/query?"+r.URL.RawQuery), http.StatusFound)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
reactAssetsRoot := "/static/react-app"
|
reactAssetsRoot := "/static/react-app"
|
||||||
if h.options.UseNewUI {
|
if h.options.UseNewUI {
|
||||||
reactAssetsRoot = "/static/mantine-ui"
|
reactAssetsRoot = "/static/mantine-ui"
|
||||||
|
@ -426,6 +448,13 @@ func New(logger log.Logger, o *Options) *Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve the React app.
|
// Serve the React app.
|
||||||
|
reactRouterPaths := oldUIReactRouterPaths
|
||||||
|
reactRouterServerPaths := oldUIReactRouterServerPaths
|
||||||
|
if h.options.UseNewUI {
|
||||||
|
reactRouterPaths = newUIReactRouterPaths
|
||||||
|
reactRouterServerPaths = newUIReactRouterServerPaths
|
||||||
|
}
|
||||||
|
|
||||||
for _, p := range reactRouterPaths {
|
for _, p := range reactRouterPaths {
|
||||||
router.Get(p, serveReactApp)
|
router.Get(p, serveReactApp)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue