-
Notifications
You must be signed in to change notification settings - Fork 29
/
stats.go
62 lines (50 loc) · 2.19 KB
/
stats.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
package tally
import (
"fmt"
"github.com/prometheus/client_golang/prometheus"
)
var registerStats = true
func (r *Recorder) createStats() {
r.okEvents = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_good_events", r.options.StatPrefix),
Help: "The number of successfully parsed events received",
}, []string{"component"})
r.badEvents = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_process_errors", r.options.StatPrefix),
Help: "The number of events received that failed to process",
}, []string{"component"})
r.eventTypes = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_event_types", r.options.StatPrefix),
Help: "The number events received by type",
}, []string{"component", "type"})
r.eventsTally = prometheus.NewGaugeVec(prometheus.GaugeOpts{
Name: fmt.Sprintf("%s_versions", r.options.StatPrefix),
Help: "The number of observations for a specific version",
}, []string{"component", "version"})
r.maintTime = prometheus.NewSummaryVec(prometheus.SummaryOpts{
Name: fmt.Sprintf("%s_maintenance_time", r.options.StatPrefix),
Help: "The time taken to perform maintenance",
}, []string{"component"})
r.processTime = prometheus.NewSummaryVec(prometheus.SummaryOpts{
Name: fmt.Sprintf("%s_processing_time", r.options.StatPrefix),
Help: "The time taken to process events",
}, []string{"component"})
r.transitionEvent = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_machine_transition", r.options.StatPrefix),
Help: "Machine state transition",
}, []string{"machine", "version", "transition", "from", "to"})
r.nodesExpired = prometheus.NewCounterVec(prometheus.CounterOpts{
Name: fmt.Sprintf("%s_nodes_expired", r.options.StatPrefix),
Help: "The number of nodes that were expired after not receiving alive events",
}, []string{"component"})
if registerStats {
prometheus.MustRegister(r.okEvents)
prometheus.MustRegister(r.badEvents)
prometheus.MustRegister(r.eventTypes)
prometheus.MustRegister(r.eventsTally)
prometheus.MustRegister(r.maintTime)
prometheus.MustRegister(r.processTime)
prometheus.MustRegister(r.transitionEvent)
prometheus.MustRegister(r.nodesExpired)
}
}