forked from shamil/burrow_exporter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
52 lines (43 loc) · 1.81 KB
/
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
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/log"
"github.com/prometheus/common/version"
"github.com/shamil/burrow_exporter/exporter"
"gopkg.in/alecthomas/kingpin.v2"
)
func init() {
prometheus.MustRegister(version.NewCollector("burrow_exporter"))
}
func main() {
var (
listenAddress = kingpin.Flag("web.listen-address", "Address to listen on for web interface and telemetry.").Short('l').Default(":8237").String()
metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose metrics.").Default("/metrics").String()
burrowAddress = kingpin.Flag("burrow.address", "Burrow API address.").Default("http://localhost:8000").String()
burrowAPIVersion = kingpin.Flag("burrow.api-version", "Burrow API version to leverage.").Default("3").Int()
collectorDisabledMetrics = kingpin.Flag("collector.disabled-metrics", "Comma separated list of metrics to disable (one of: consumer-status, partition-current-offset, partition-lag, partition-max-offset, partition-status, topic-partition-offset, total-lag).").Default("").String()
)
log.AddFlags(kingpin.CommandLine)
kingpin.Version(version.Print("burrow_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()
c := exporter.NewCollector(
*burrowAddress,
*burrowAPIVersion,
*collectorDisabledMetrics,
)
prometheus.MustRegister(c)
http.Handle(*metricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>Burrow Exporter</title></head>
<body>
<h1>Burrow Exporter</h1>
<p><a href="` + *metricsPath + `">Metrics</a></p>
</body>
</html>`))
})
log.Fatal(http.ListenAndServe(*listenAddress, nil))
}