-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.go
37 lines (32 loc) · 953 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package main
import (
"fmt"
"net/http"
"os"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
)
func healthz(response http.ResponseWriter, request *http.Request) {
fmt.Fprintln(response, "ok")
}
func main() {
c, err := NewCollector("https://api.qrator.net/request", os.Getenv("QRATOR_CLIENT_ID"), os.Getenv("QRATOR_X_QRATOR_AUTH"))
if err != nil {
log.Fatalf("Can't create collector: %v", err)
}
prometheus.MustRegister(c)
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/healthz", healthz)
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>Qrator Exporter</title></head>
<body>
<h1>Qrator Exporter</h1>
<p><a href="/metrics">Metrics</a></p>
</body>
</html>`))
})
log.Infoln("Starting qrator-exporter")
log.Fatal(http.ListenAndServe(":9502", nil))
}