forked from EladLeev/kafka-config-metrics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
39 lines (32 loc) · 1009 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
38
39
package main
import (
"fmt"
"net/http"
"time"
"github.com/EladLeev/kafka-config-metrics/util"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
)
func main() {
// Init config and logger
util.InitLog(util.Configuration)
log.Infof(" \\ʕ ◔ ϖ ◔ ʔ/ ## Kafka-Config-Metrics-Exporter ## \\ʕ ◔ ϖ ◔ ʔ/\n")
log.Debugf("cfg: %+v", util.Configuration)
// Init Prometheus metrics
util.InitProm()
// Exspose Prometheus endpoints
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "OK")
})
http.HandleFunc("/-/ready", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "OK")
})
server := &http.Server{
Addr: util.Configuration.Global.Port,
ReadHeaderTimeout: time.Duration(util.Configuration.Global.Timeout) * time.Second,
}
log.Fatal(server.ListenAndServe())
}