diff --git a/server/server.go b/server/server.go index dce01f4b..17a55b47 100644 --- a/server/server.go +++ b/server/server.go @@ -150,12 +150,14 @@ func New(cfg Config) (*Server, error) { // Setup HTTP server router := mux.NewRouter() - if cfg.RegisterInstrumentation { - RegisterInstrumentation(router) - } if cfg.PathPrefix != "" { + // Expect metrics and pprof handlers to be prefixed with server's path prefix. + // e.g. /loki/metrics or /loki/debug/pprof router = router.PathPrefix(cfg.PathPrefix).Subrouter() } + if cfg.RegisterInstrumentation { + RegisterInstrumentation(router) + } httpMiddleware := []middleware.Interface{ middleware.Tracer{ RouteMatcher: router,