-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
47 lines (40 loc) · 1.08 KB
/
metrics.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
package main
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
log "github.com/sirupsen/logrus"
)
var (
bgpPathAdvertisement = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: "bgp_lb_path_advertisement",
Help: "Info about whether a path is advertised via the bgp daemon. It can be 0 or 1.",
},
[]string{
"prefix",
"prefix_length",
"next_hop",
},
)
)
func init() {
prometheus.MustRegister(bgpPathAdvertisement)
}
func setBGPPathAdvertisementMetric(prefix, prefixLen, nexthop string) {
bgpPathAdvertisement.With(prometheus.Labels{
"prefix": prefix,
"prefix_length": prefixLen,
"next_hop": nexthop,
}).Set(1)
}
func unsetBGPPathAdvertisementMetric(prefix, prefixLen, nexthop string) {
bgpPathAdvertisement.With(prometheus.Labels{
"prefix": prefix,
"prefix_length": prefixLen,
"next_hop": nexthop,
}).Set(0)
}
func startMetricsServer(listenAddress string) {
http.Handle("/metrics", promhttp.Handler())
log.Fatal(http.ListenAndServe(listenAddress, nil))
}