Skip to content

Commit

Permalink
Allow root path as metrics path. (prometheus#2590)
Browse files Browse the repository at this point in the history
Signed-off-by: LamGC <lam827@lamgc.net>
  • Loading branch information
LamGC authored and oblitorum committed Apr 9, 2024
1 parent add1f0b commit 1ea991b
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions node_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,25 @@ func main() {
level.Debug(logger).Log("msg", "Go MAXPROCS", "procs", runtime.GOMAXPROCS(0))

http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger))
landingConfig := web.LandingConfig{
Name: "Node Exporter",
Description: "Prometheus Node Exporter",
Version: version.Info(),
Links: []web.LandingLinks{
{
Address: *metricsPath,
Text: "Metrics",
if *metricsPath != "/" {
landingConfig := web.LandingConfig{
Name: "Node Exporter",
Description: "Prometheus Node Exporter",
Version: version.Info(),
Links: []web.LandingLinks{
{
Address: *metricsPath,
Text: "Metrics",
},
},
},
}
landingPage, err := web.NewLandingPage(landingConfig)
if err != nil {
level.Error(logger).Log("err", err)
os.Exit(1)
}
landingPage, err := web.NewLandingPage(landingConfig)
if err != nil {
level.Error(logger).Log("err", err)
os.Exit(1)
}
http.Handle("/", landingPage)
}
http.Handle("/", landingPage)

server := &http.Server{}
if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil {
Expand Down

0 comments on commit 1ea991b

Please sign in to comment.