From 3c9a0052f2d8dd2af99f7515521e3a7d39c6f743 Mon Sep 17 00:00:00 2001 From: Hector Date: Fri, 24 Sep 2021 15:53:10 +0100 Subject: [PATCH] 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. --- src/exporter.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/exporter.go b/src/exporter.go index 6cc8793..59874e6 100644 --- a/src/exporter.go +++ b/src/exporter.go @@ -40,6 +40,15 @@ func main() { exporter := export.NewExporter(appSettings, version) prometheus.MustRegister(exporter) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(` + Fail2Ban Exporter + +

Node Exporter

+

Metrics

+ + `)) + }) http.Handle(metricsPath, promhttp.Handler()) log.Printf("metrics available at '%s'", metricsPath)