diff --git a/go.mod b/go.mod index 9c3fc5e02423..eaf53f270391 100644 --- a/go.mod +++ b/go.mod @@ -19,6 +19,7 @@ require ( github.com/drone/envsubst v1.0.2 github.com/dustin/go-humanize v1.0.0 github.com/fatih/color v1.9.0 + github.com/felixge/fgprof v0.9.1 github.com/fluent/fluent-bit-go v0.0.0-20190925192703-ea13c021720c github.com/go-kit/kit v0.10.0 github.com/go-logfmt/logfmt v0.5.0 diff --git a/pkg/loki/loki.go b/pkg/loki/loki.go index 59a97f2e6c08..2e2d384a9adf 100644 --- a/pkg/loki/loki.go +++ b/pkg/loki/loki.go @@ -9,6 +9,7 @@ import ( frontend "github.com/cortexproject/cortex/pkg/frontend/v1" "github.com/cortexproject/cortex/pkg/querier/worker" + "github.com/felixge/fgprof" "github.com/grafana/loki/pkg/storage/stores/shipper/compactor" @@ -239,6 +240,8 @@ func (t *Loki) Run() error { // This adds a way to see the config and the changes compared to the defaults t.Server.HTTP.Path("/config").HandlerFunc(configHandler(t.cfg, newDefaultConfig())) + t.Server.HTTP.Path("/debug/fgprof").Handler(fgprof.Handler()) + // Let's listen for events from this manager, and log them. healthy := func() { level.Info(util_log.Logger).Log("msg", "Loki started") } stopped := func() { level.Info(util_log.Logger).Log("msg", "Loki stopped") } diff --git a/pkg/promtail/server/server.go b/pkg/promtail/server/server.go index 8f20d66c2f31..14f3519581db 100644 --- a/pkg/promtail/server/server.go +++ b/pkg/promtail/server/server.go @@ -13,6 +13,7 @@ import ( "syscall" "text/template" + "github.com/felixge/fgprof" "github.com/go-kit/kit/log" "github.com/go-kit/kit/log/level" "github.com/pkg/errors" @@ -99,8 +100,8 @@ func New(cfg Config, log log.Logger, tms *targets.TargetManagers) (Server, error serv.HTTP.PathPrefix("/static/").Handler(http.FileServer(ui.Assets)) serv.HTTP.Path("/service-discovery").Handler(http.HandlerFunc(serv.serviceDiscovery)) serv.HTTP.Path("/targets").Handler(http.HandlerFunc(serv.targets)) + serv.HTTP.Path("/debug/fgprof").Handler(fgprof.Handler()) return serv, nil - } // serviceDiscovery serves the service discovery page. @@ -261,6 +262,7 @@ func (s *noopServer) Run() error { level.Info(s.log).Log("msg", "received shutdown signal", "sig", sig) return nil } + func (s *noopServer) Shutdown() { s.sigs <- syscall.SIGTERM } diff --git a/vendor/modules.txt b/vendor/modules.txt index 58dbe93607bc..bd374b740ed3 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -351,6 +351,7 @@ github.com/facette/natsort ## explicit github.com/fatih/color # github.com/felixge/fgprof v0.9.1 +## explicit github.com/felixge/fgprof # github.com/felixge/httpsnoop v1.0.1 github.com/felixge/httpsnoop