diff --git a/cmd/exporters/prometheus/httpd.go b/cmd/exporters/prometheus/httpd.go index ebc1351e8..bf8036d7d 100644 --- a/cmd/exporters/prometheus/httpd.go +++ b/cmd/exporters/prometheus/httpd.go @@ -13,6 +13,7 @@ import ( "github.com/netapp/harvest/v2/pkg/set" "net" "net/http" + "net/http/pprof" "strconv" "strings" "time" @@ -23,6 +24,11 @@ func (p *Prometheus) startHTTPD(addr string, port int) { mux := http.NewServeMux() mux.HandleFunc("/", p.ServeInfo) mux.HandleFunc("/metrics", p.ServeMetrics) + mux.HandleFunc("localhost/debug/pprof/", pprof.Index) + mux.HandleFunc("localhost/debug/pprof/cmdline", pprof.Cmdline) + mux.HandleFunc("localhost/debug/pprof/profile", pprof.Profile) + mux.HandleFunc("localhost/debug/pprof/symbol", pprof.Symbol) + mux.HandleFunc("localhost/debug/pprof/trace", pprof.Trace) server := &http.Server{ Addr: addr + ":" + strconv.Itoa(port), diff --git a/cmd/poller/poller.go b/cmd/poller/poller.go index be0f8f81b..9125dfc67 100644 --- a/cmd/poller/poller.go +++ b/cmd/poller/poller.go @@ -205,7 +205,9 @@ func (p *Poller) Init() error { logger = logging.Configure(logConfig) - // if profiling port > 0 start profiling service + // If profiling port > 0, start an HTTP server on that port with the profiling endpoints setup. + // When using the Prometheus exporter, the profiling endpoints will be setup automatically in + // cmd/exporters/prometheus/httpd.go if p.options.Profiling > 0 { addr := fmt.Sprintf("localhost:%d", p.options.Profiling) logger.Info().Msgf("profiling enabled on [%s]", addr)