feat: render basic html page at root url
Add a new request handler for the root URL (`/`) to render a simple HTML page with a link to the metrics page. This follows the convention of other metric exporters.
This commit is contained in:
parent
a1a0aa03a4
commit
3c9a0052f2
@ -40,6 +40,15 @@ func main() {
|
|||||||
exporter := export.NewExporter(appSettings, version)
|
exporter := export.NewExporter(appSettings, version)
|
||||||
prometheus.MustRegister(exporter)
|
prometheus.MustRegister(exporter)
|
||||||
|
|
||||||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
w.Write([]byte(`<html>
|
||||||
|
<head><title>Fail2Ban Exporter</title></head>
|
||||||
|
<body>
|
||||||
|
<h1>Node Exporter</h1>
|
||||||
|
<p><a href="` + metricsPath + `">Metrics</a></p>
|
||||||
|
</body>
|
||||||
|
</html>`))
|
||||||
|
})
|
||||||
http.Handle(metricsPath, promhttp.Handler())
|
http.Handle(metricsPath, promhttp.Handler())
|
||||||
log.Printf("metrics available at '%s'", metricsPath)
|
log.Printf("metrics available at '%s'", metricsPath)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user