-
Notifications
You must be signed in to change notification settings - Fork 15
/
RocketmqExporter.go
41 lines (31 loc) · 1.13 KB
/
RocketmqExporter.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
package main
import (
"RocketmqExporter/constant"
"fmt"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"github.com/prometheus/common/promlog"
"github.com/prometheus/common/promlog/flag"
"github.com/prometheus/common/version"
"gopkg.in/alecthomas/kingpin.v2"
"net/http"
)
func main() {
promlogConfig := &promlog.Config{}
flag.AddFlags(kingpin.CommandLine, promlogConfig)
kingpin.Version(version.Print("rocketmq_exporter"))
kingpin.HelpFlag.Short('h')
kingpin.Parse()
logger := promlog.New(promlogConfig)
level.Info(logger).Log("msg", "Starting rocketmq_exporter", "version", version.Info)
level.Info(logger).Log("msg", "Build contenxt", version.BuildContext())
metricsPath := constant.GetMetricsPath()
listenAddress := constant.GetListenAddress()
metricsPrefix := constant.GetMetricsPrefix()
level.Info(logger).Log("msg", "fmt.metricsPath:"+metricsPath)
exporter := DeclareExporter(metricsPrefix)
prometheus.MustRegister(exporter)
http.Handle(metricsPath, promhttp.Handler())
fmt.Println(http.ListenAndServe(listenAddress, nil))
}