Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add fgprof to Loki and Promtail. #3424

Merged
merged 1 commit into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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") }
Expand Down
4 changes: 3 additions & 1 deletion pkg/promtail/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
1 change: 1 addition & 0 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down