-
Notifications
You must be signed in to change notification settings - Fork 41
/
prometheus.go
108 lines (102 loc) · 3.12 KB
/
prometheus.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package main
import (
"time"
"github.com/prometheus/client_golang/prometheus"
)
const ns = "nixy"
var (
countFailedReloads = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "reloads_failed",
Help: "Total number of failed Nginx reloads",
},
)
countSuccessfulReloads = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "reloads_successful",
Help: "Total number of successful Nginx reloads",
},
)
histogramReloadDuration = prometheus.NewHistogram(
prometheus.HistogramOpts{
Namespace: ns,
Name: "reload_duration",
Help: "Nginx reload duration",
Buckets: prometheus.ExponentialBuckets(0.05, 2, 10),
},
)
countInvalidSubdomainLabelWarnings = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "invalid_subdomain_label_warnings",
Help: "Total number of warnings about invalid subdomain label",
},
)
countDuplicateSubdomainLabelWarnings = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "duplicate_subdomain_label_warnings",
Help: "Total number of warnings about duplicate subdomain label",
},
)
countEndpointCheckFails = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "endpoint_check_fails",
Help: "Total number of endpoint check failure errors",
},
)
countEndpointDownErrors = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "endpoint_down_errors",
Help: "Total number of endpoint down errors",
},
)
countAllEndpointsDownErrors = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "all_endpoints_down_errors",
Help: "Total number of all endpoints down errors",
},
)
countMarathonStreamErrors = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "marathon_stream_errors",
Help: "Total number of Marathon stream errors",
},
)
countMarathonStreamNoDataWarnings = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "marathon_stream_no_data_warnings",
Help: "Total number of warnings about no data in Marathon stream",
},
)
countMarathonEventsReceived = prometheus.NewCounter(
prometheus.CounterOpts{
Namespace: ns,
Name: "marathon_events_received",
Help: "Total number of received Marathon events",
},
)
)
func setupPrometheusMetrics() {
prometheus.MustRegister(countFailedReloads)
prometheus.MustRegister(countSuccessfulReloads)
prometheus.MustRegister(histogramReloadDuration)
prometheus.MustRegister(countInvalidSubdomainLabelWarnings)
prometheus.MustRegister(countDuplicateSubdomainLabelWarnings)
prometheus.MustRegister(countEndpointCheckFails)
prometheus.MustRegister(countEndpointDownErrors)
prometheus.MustRegister(countAllEndpointsDownErrors)
prometheus.MustRegister(countMarathonStreamErrors)
prometheus.MustRegister(countMarathonStreamNoDataWarnings)
prometheus.MustRegister(countMarathonEventsReceived)
}
func observeReloadTimeMetric(e time.Duration) {
histogramReloadDuration.Observe(float64(e) / float64(time.Second))
}