Allow root path as metrics path. (#2590)

Signed-off-by: LamGC <lam827@lamgc.net>
This commit is contained in:
LamGC 2023-03-09 00:15:39 +08:00 committed by GitHub
parent bb5ecb73d7
commit c13f808619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -186,23 +186,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)
}
http.Handle("/", landingPage)
}
landingPage, err := web.NewLandingPage(landingConfig)
if err != nil {
level.Error(logger).Log("err", err)
os.Exit(1)
}
http.Handle("/", landingPage)
server := &http.Server{}
if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil {