diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index ff2eec9..1d0b0ba 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -6,24 +6,26 @@ import ( ) type Metrics struct { - BlockNumber prometheus.Gauge - ChainID *prometheus.GaugeVec - CurrentProposals *prometheus.GaugeVec - EpochLength prometheus.Gauge - EpochStartHeight prometheus.Gauge - NextValidatorStake *prometheus.GaugeVec - PrevEpochKickout *prometheus.GaugeVec - ProtocolVersion prometheus.Gauge - SeatPrice prometheus.Gauge - SyncingDesc prometheus.Gauge - ValidatorExpectedBlocks *prometheus.GaugeVec - ValidatorExpectedChunks *prometheus.GaugeVec - ValidatorProducedBlocks *prometheus.GaugeVec - ValidatorProducedChunks *prometheus.GaugeVec - ValidatorSlashed *prometheus.GaugeVec - ValidatorStake *prometheus.GaugeVec - ValidatorRank *prometheus.GaugeVec - VersionBuild *prometheus.GaugeVec + BlockNumber prometheus.Gauge + ChainID *prometheus.GaugeVec + CurrentProposals *prometheus.GaugeVec + EpochLength prometheus.Gauge + EpochStartHeight prometheus.Gauge + NextValidatorStake *prometheus.GaugeVec + PrevEpochKickout *prometheus.GaugeVec + ProtocolVersion prometheus.Gauge + SeatPrice prometheus.Gauge + SyncingDesc prometheus.Gauge + ValidatorExpectedBlocks *prometheus.GaugeVec + ValidatorExpectedChunks *prometheus.GaugeVec + ValidatorExpectedEndorsements *prometheus.GaugeVec + ValidatorProducedBlocks *prometheus.GaugeVec + ValidatorProducedChunks *prometheus.GaugeVec + ValidatorProducedEndorsements *prometheus.GaugeVec + ValidatorSlashed *prometheus.GaugeVec + ValidatorStake *prometheus.GaugeVec + ValidatorRank *prometheus.GaugeVec + VersionBuild *prometheus.GaugeVec } func New(namespace string) *Metrics { @@ -94,6 +96,12 @@ func New(namespace string) *Metrics { Help: "Current amount of validator expected chunks"}, []string{"account_id", "public_key", "epoch_start_height", "tracked"}, ), + ValidatorExpectedEndorsements: prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Namespace: namespace, + Name: "validator_endorsements_expected", + Help: "Current amount of validator expected endorsements"}, + []string{"account_id", "public_key", "epoch_start_height", "tracked"}, + ), ValidatorProducedBlocks: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace, Name: "validator_blocks_produced", @@ -106,6 +114,12 @@ func New(namespace string) *Metrics { Help: "Current amount of validator produced chunks"}, []string{"account_id", "public_key", "epoch_start_height", "tracked"}, ), + ValidatorProducedEndorsements: prometheus.NewGaugeVec(prometheus.GaugeOpts{ + Namespace: namespace, + Name: "validator_endorsements_produced", + Help: "Current amount of validator produced endorsements"}, + []string{"account_id", "public_key", "epoch_start_height", "tracked"}, + ), ValidatorSlashed: prometheus.NewGaugeVec(prometheus.GaugeOpts{ Namespace: namespace, Name: "validator_slashed", @@ -149,8 +163,10 @@ func (m *Metrics) Register(reg prometheus.Registerer) { reg.MustRegister(m.SyncingDesc) reg.MustRegister(m.ValidatorExpectedBlocks) reg.MustRegister(m.ValidatorExpectedChunks) + reg.MustRegister(m.ValidatorExpectedEndorsements) reg.MustRegister(m.ValidatorProducedBlocks) reg.MustRegister(m.ValidatorProducedChunks) + reg.MustRegister(m.ValidatorProducedEndorsements) reg.MustRegister(m.ValidatorSlashed) reg.MustRegister(m.ValidatorStake) reg.MustRegister(m.ValidatorRank) diff --git a/pkg/near/validators.go b/pkg/near/validators.go index 7927b12..6c18485 100644 --- a/pkg/near/validators.go +++ b/pkg/near/validators.go @@ -9,12 +9,14 @@ import ( type ValidatorsResponse struct { CurrentValidators []struct { Validator - IsSlashed bool `json:"is_slashed"` - Shards []int `json:"shards"` - NumProducedBlocks int64 `json:"num_produced_blocks"` - NumExpectedBlocks int64 `json:"num_expected_blocks"` - NumProducedChunks int64 `json:"num_produced_chunks"` - NumExpectedChunks int64 `json:"num_expected_chunks"` + IsSlashed bool `json:"is_slashed"` + Shards []int `json:"shards"` + NumProducedBlocks int64 `json:"num_produced_blocks"` + NumExpectedBlocks int64 `json:"num_expected_blocks"` + NumProducedChunks int64 `json:"num_produced_chunks"` + NumExpectedChunks int64 `json:"num_expected_chunks"` + NumProducedEndorsements int64 `json:"num_produced_endorsements"` + NumExpectedEndorsements int64 `json:"num_expected_endorsements"` } `json:"current_validators"` NextValidators []struct { Validator diff --git a/pkg/watcher/watcher.go b/pkg/watcher/watcher.go index 02191f2..7604dd0 100644 --- a/pkg/watcher/watcher.go +++ b/pkg/watcher/watcher.go @@ -128,8 +128,10 @@ func (w *Watcher) collectValidators(ctx context.Context) (near.ValidatorsRespons // Reset labeled gauge vec w.metrics.ValidatorExpectedBlocks.Reset() w.metrics.ValidatorExpectedChunks.Reset() + w.metrics.ValidatorExpectedEndorsements.Reset() w.metrics.ValidatorProducedBlocks.Reset() w.metrics.ValidatorProducedChunks.Reset() + w.metrics.ValidatorProducedEndorsements.Reset() w.metrics.ValidatorSlashed.Reset() w.metrics.ValidatorStake.Reset() w.metrics.ValidatorRank.Reset() @@ -158,8 +160,10 @@ func (w *Watcher) collectValidators(ctx context.Context) (near.ValidatorsRespons w.metrics.ValidatorExpectedBlocks.WithLabelValues(labels...).Set(float64(v.NumExpectedBlocks)) w.metrics.ValidatorExpectedChunks.WithLabelValues(labels...).Set(float64(v.NumExpectedChunks)) + w.metrics.ValidatorExpectedEndorsements.WithLabelValues(labels...).Set(float64(v.NumExpectedEndorsements)) w.metrics.ValidatorProducedBlocks.WithLabelValues(labels...).Set(float64(v.NumProducedBlocks)) w.metrics.ValidatorProducedChunks.WithLabelValues(labels...).Set(float64(v.NumProducedChunks)) + w.metrics.ValidatorProducedEndorsements.WithLabelValues(labels...).Set(float64(v.NumProducedEndorsements)) w.metrics.ValidatorSlashed.WithLabelValues(labels...).Set(metrics.BoolToFloat64(v.IsSlashed)) w.metrics.ValidatorStake.WithLabelValues(labels...).Set(v.Stake.Div(yoctoUnit).InexactFloat64())