-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
48 lines (39 loc) · 1.06 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
package main
import (
"flag"
"io/ioutil"
"net/http"
yaml "gopkg.in/yaml.v2"
"github.com/deepthawtz/prom-sidekiq-exporter/exporter"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/sirupsen/logrus"
)
func main() {
var config = flag.String("config", "./config.yml", "Path to config file (default: ./config.yml)")
flag.Parse()
y, err := ioutil.ReadFile(*config)
if err != nil {
logrus.Fatal(err)
}
c := &exporter.Config{}
if err := yaml.Unmarshal(y, c); err != nil {
logrus.Fatal(err)
}
exp, err := exporter.NewExporter(c)
if err != nil {
logrus.Fatal(err)
}
prometheus.MustRegister(exp)
http.Handle("/metrics", promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
<head><title>Prometheus Sidekiq Exporter</title></head>
<body>
<h1>Prometheus Sidekiq Exporter</h1>
<p><a href="/metrics">Metrics</a></p>
</body></html>`))
})
logrus.Info("Listening on port 9090")
logrus.Fatal(http.ListenAndServe(":9090", nil))
}