Skip to content

Commit

Permalink
feat: add not active metric
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Jul 24, 2023
1 parent 408e3df commit 7bf60a8
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ type Manager struct {
reporterEnabledGauge *prometheus.GaugeVec
reporterQueriesCounter *prometheus.CounterVec

missingBlocksGauge *prometheus.GaugeVec
activeBlocksGauge *prometheus.GaugeVec
isActiveGauge *prometheus.GaugeVec
isJailedGauge *prometheus.GaugeVec
isTombstonedGauge *prometheus.GaugeVec
missingBlocksGauge *prometheus.GaugeVec
activeBlocksGauge *prometheus.GaugeVec
notActiveBlocksGauge *prometheus.GaugeVec

isActiveGauge *prometheus.GaugeVec
isJailedGauge *prometheus.GaugeVec
isTombstonedGauge *prometheus.GaugeVec

appVersionGauge *prometheus.GaugeVec
chainInfoGauge *prometheus.GaugeVec
Expand Down Expand Up @@ -113,6 +115,10 @@ func NewManager(logger zerolog.Logger, config configPkg.MetricsConfig) *Manager
Name: constants.PrometheusMetricsPrefix + "active_blocks",
Help: "Count of each validator's blocks during which they were active",
}, []string{"chain", "moniker", "address"}),
notActiveBlocksGauge: promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: constants.PrometheusMetricsPrefix + "not_active_blocks",
Help: "Count of each validator's blocks during which they were not active",
}, []string{"chain", "moniker", "address"}),
isActiveGauge: promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: constants.PrometheusMetricsPrefix + "active",
Help: "Whether the validator is active",
Expand Down Expand Up @@ -295,6 +301,14 @@ func (m *Manager) LogValidatorStats(
}).
Set(float64(signatureInfo.Active))

m.notActiveBlocksGauge.
With(prometheus.Labels{
"chain": chain,
"moniker": validator.Moniker,
"address": validator.OperatorAddress,
}).
Set(float64(signatureInfo.NotActive))

m.isActiveGauge.
With(prometheus.Labels{
"chain": chain,
Expand Down

0 comments on commit 7bf60a8

Please sign in to comment.