-
Notifications
You must be signed in to change notification settings - Fork 3
/
prometheus.go
100 lines (87 loc) · 3.59 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
package watcher
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
log "github.com/sirupsen/logrus"
)
// Prometheus metrics exposed by the watcher.
type WatcherMetrics struct {
ratedMonitoredKeys prometheus.Gauge
ratedMonitoredByLabel *prometheus.GaugeVec
ratedValidationUptime *prometheus.GaugeVec
ratedValidationAvgCorrectness *prometheus.GaugeVec
ratedValidationAttesterEffectiveness *prometheus.GaugeVec
ratedValidationProposerEffectiveness *prometheus.GaugeVec
ratedValidationValidatorEffectiveness *prometheus.GaugeVec
ratedValidationRewards *prometheus.GaugeVec
ratedValidationInclusionDelay *prometheus.GaugeVec
}
// NewWatcherMetrics creates prometheus metrics for the watcher.
func NewWatcherMetrics(reg prometheus.Registerer) *WatcherMetrics {
log.Info("creating Prometheus metrics for watcher")
monitored := promauto.With(reg).NewGauge(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "monitored_keys",
Help: "Number of validation keys watched.",
})
monitoredByLabel := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "monitored_keys_per_label",
Help: "Number of validation keys watched per label.",
}, []string{"label"})
uptime := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_uptime",
Help: "Uptime of a validation key.",
}, []string{"label", "pubkey"})
correctness := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_correctness",
Help: "Average correctness of a validation key.",
}, []string{"label", "pubkey"})
attester := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_attester_effectiveness",
Help: "Attester effectiveness of a validation key.",
}, []string{"label", "pubkey"})
proposer := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_proposer_effectiveness",
Help: "Proposer effectiveness of a validation key.",
}, []string{"label", "pubkey"})
effectiveness := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_effectiveness",
Help: "Effectiveness of a validation key.",
}, []string{"label", "pubkey"})
rewards := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_rewards",
Help: "All consensus and execution layer rewards for the key.",
}, []string{"label", "pubkey"})
delay := promauto.With(reg).NewGaugeVec(prometheus.GaugeOpts{
Namespace: "rated",
Subsystem: "sentinel",
Name: "validation_key_inclusion_delay",
Help: "Average inclusion delay for the observed period.",
}, []string{"label", "pubkey"})
return &WatcherMetrics{
ratedMonitoredKeys: monitored,
ratedMonitoredByLabel: monitoredByLabel,
ratedValidationUptime: uptime,
ratedValidationAvgCorrectness: correctness,
ratedValidationAttesterEffectiveness: attester,
ratedValidationProposerEffectiveness: proposer,
ratedValidationValidatorEffectiveness: effectiveness,
ratedValidationRewards: rewards,
ratedValidationInclusionDelay: delay,
}
}