-
Notifications
You must be signed in to change notification settings - Fork 456
/
Copy pathproxy.go
46 lines (39 loc) · 1019 Bytes
/
proxy.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
package collectors
import (
"github.com/prometheus/client_golang/prometheus"
)
type ProxyMetricCollectors struct {
collectors []prometheus.Collector
proxyLabels []string
ReceivedBytesTotal *prometheus.CounterVec
SentBytesTotal *prometheus.CounterVec
}
func (c *ProxyMetricCollectors) Collectors() []prometheus.Collector {
return c.collectors
}
func NewProxyMetricCollectors() *ProxyMetricCollectors {
var m ProxyMetricCollectors
m.proxyLabels = []string{
"direction",
"proxy",
"listener",
"upstream",
}
m.ReceivedBytesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "proxy",
Name: "received_bytes_total",
},
m.proxyLabels)
m.collectors = append(m.collectors, m.ReceivedBytesTotal)
m.SentBytesTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Subsystem: "proxy",
Name: "sent_bytes_total",
},
m.proxyLabels)
m.collectors = append(m.collectors, m.SentBytesTotal)
return &m
}