Skip to content

Commit 51209c9

Browse files
LamGCoblitorum
authored andcommitted
Allow root path as metrics path. (prometheus#2590)
Signed-off-by: LamGC <[email protected]>
1 parent dcb5857 commit 51209c9

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

node_exporter.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -251,23 +251,25 @@ func main() {
251251
level.Debug(logger).Log("msg", "Go MAXPROCS", "procs", runtime.GOMAXPROCS(0))
252252

253253
http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger))
254-
landingConfig := web.LandingConfig{
255-
Name: "Node Exporter",
256-
Description: "Prometheus Node Exporter",
257-
Version: version.Info(),
258-
Links: []web.LandingLinks{
259-
{
260-
Address: *metricsPath,
261-
Text: "Metrics",
254+
if *metricsPath != "/" {
255+
landingConfig := web.LandingConfig{
256+
Name: "Node Exporter",
257+
Description: "Prometheus Node Exporter",
258+
Version: version.Info(),
259+
Links: []web.LandingLinks{
260+
{
261+
Address: *metricsPath,
262+
Text: "Metrics",
263+
},
262264
},
263-
},
264-
}
265-
landingPage, err := web.NewLandingPage(landingConfig)
266-
if err != nil {
267-
level.Error(logger).Log("err", err)
268-
os.Exit(1)
265+
}
266+
landingPage, err := web.NewLandingPage(landingConfig)
267+
if err != nil {
268+
level.Error(logger).Log("err", err)
269+
os.Exit(1)
270+
}
271+
http.Handle("/", landingPage)
269272
}
270-
http.Handle("/", landingPage)
271273

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

0 commit comments

Comments
 (0)