From 9119e6d08f4854997dee0e1d826af122eae98c69 Mon Sep 17 00:00:00 2001 From: Sharif Nassar Date: Wed, 14 Jun 2017 16:00:32 -0700 Subject: [PATCH 1/2] Handle requests to / This lets us do health checks against the exporter without having to collect all the metrics. For now, just print the version. --- main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/main.go b/main.go index 5d4fef9..02ddeb1 100644 --- a/main.go +++ b/main.go @@ -64,6 +64,9 @@ func Run(args []string) { prometheus.MustRegister(exporter) http.Handle("/metrics", prometheus.Handler()) + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(fmt.Sprintf("%s/%s\n", ver, rev))) + }) addr := fmt.Sprintf(":%d", port) log.Print("Listening 0.0.0.0", addr) From 32029929a4bebd62a72d8210b4b89e97f6b44389 Mon Sep 17 00:00:00 2001 From: Sharif Nassar Date: Thu, 15 Jun 2017 08:27:18 -0700 Subject: [PATCH 2/2] Convert root URL to "pretty" HTML per best practices https://prometheus.io/docs/instrumenting/writing_exporters/#landing-page --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 02ddeb1..29aefc9 100644 --- a/main.go +++ b/main.go @@ -65,7 +65,14 @@ func Run(args []string) { http.Handle("/metrics", prometheus.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(fmt.Sprintf("%s/%s\n", ver, rev))) + w.Write([]byte(` + + +

Resque Exporter v` + ver + `/` + rev + `

+

Metrics

+ + + `)) }) addr := fmt.Sprintf(":%d", port)