mirror of
				https://github.com/prometheus/node_exporter.git
				synced 2025-08-20 18:33:52 -07:00 
			
		
		
		
	Allow root path as metrics path. (#2590)
Signed-off-by: LamGC <lam827@lamgc.net>
This commit is contained in:
		
							parent
							
								
									bb5ecb73d7
								
							
						
					
					
						commit
						c13f808619
					
				|  | @ -186,23 +186,25 @@ func main() { | ||||||
| 	level.Debug(logger).Log("msg", "Go MAXPROCS", "procs", runtime.GOMAXPROCS(0)) | 	level.Debug(logger).Log("msg", "Go MAXPROCS", "procs", runtime.GOMAXPROCS(0)) | ||||||
| 
 | 
 | ||||||
| 	http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger)) | 	http.Handle(*metricsPath, newHandler(!*disableExporterMetrics, *maxRequests, logger)) | ||||||
| 	landingConfig := web.LandingConfig{ | 	if *metricsPath != "/" { | ||||||
| 		Name:        "Node Exporter", | 		landingConfig := web.LandingConfig{ | ||||||
| 		Description: "Prometheus Node Exporter", | 			Name:        "Node Exporter", | ||||||
| 		Version:     version.Info(), | 			Description: "Prometheus Node Exporter", | ||||||
| 		Links: []web.LandingLinks{ | 			Version:     version.Info(), | ||||||
| 			{ | 			Links: []web.LandingLinks{ | ||||||
| 				Address: *metricsPath, | 				{ | ||||||
| 				Text:    "Metrics", | 					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{} | 	server := &http.Server{} | ||||||
| 	if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil { | 	if err := web.ListenAndServe(server, toolkitFlags, logger); err != nil { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue