-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
40 lines (33 loc) · 943 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
40
package main
import (
"flag"
"net/http"
"os"
"github.com/nlm/briq-cli/briq"
"github.com/nlm/briq-exporter/prombriq"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
)
var (
flagListen = flag.String("listen", ":9000", "interface to listen on")
)
func main() {
flag.Parse()
logger := log.New()
// Setup briq client
secretKey := os.Getenv("BRIQ_SECRET_KEY")
if secretKey == "" {
logger.Fatal("you must define BRIQ_SECRET_KEY in the environment")
}
client, err := briq.NewClient(os.Getenv("BRIQ_SECRET_KEY"))
if err != nil {
logger.WithError(err).Fatal("unable to initialize briq client")
}
// Setup collector
collector := prombriq.NewCollector(client, prombriq.WithLogger(logger))
prometheus.MustRegister(collector)
// Listen and Serve
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(*flagListen, nil)
}