-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
34 lines (29 loc) · 889 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
package main
import (
"log"
"net/http"
"strconv"
"github.com/gopaytech/unused-exporter/pkg/collector"
"github.com/gopaytech/unused-exporter/pkg/settings"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
settings := settings.NewSettings()
collectorHandler, err := collector.NewCollector(settings)
if err != nil {
log.Fatal(err)
}
prometheus.MustRegister(collectorHandler)
http.Handle("/metrics", promhttp.Handler())
http.Handle("/healthz", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}))
http.Handle("/readyz", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
}))
err = http.ListenAndServe(":"+strconv.Itoa(settings.Port), nil)
log.Fatal(err)
}