diff --git a/pkg/metrics/metrics.go b/pkg/metrics/metrics.go index 6cfb496..35ea215 100644 --- a/pkg/metrics/metrics.go +++ b/pkg/metrics/metrics.go @@ -261,7 +261,7 @@ func New(namespace string) *Metrics { Name: "validator_balance_available", Help: "Validator balance available", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorCommission: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -269,7 +269,7 @@ func New(namespace string) *Metrics { Name: "validator_balance_commission", Help: "Validator commission", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorBalanceDelegated: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -277,7 +277,7 @@ func New(namespace string) *Metrics { Name: "validator_balance_delegated", Help: "Validator balance delegated", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorBalanceReward: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -285,7 +285,7 @@ func New(namespace string) *Metrics { Name: "validator_balance_reward", Help: "Validator balance reward", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorBalanceUnBonding: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -293,7 +293,7 @@ func New(namespace string) *Metrics { Name: "validator_balance_unbonding", Help: "Validator balance unbonding", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorDelegators: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -301,7 +301,7 @@ func New(namespace string) *Metrics { Name: "validator_delegators", Help: "Validator delegators", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorStatus: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -309,7 +309,7 @@ func New(namespace string) *Metrics { Name: "validator_status", Help: "Validator status", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorTokens: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -317,7 +317,7 @@ func New(namespace string) *Metrics { Name: "validator_tokens", Help: "Validator tokens", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorCommissionRate: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -325,7 +325,7 @@ func New(namespace string) *Metrics { Name: "validator_commission_rate", Help: "Validator commission rate", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorDelegatorShares: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -333,7 +333,7 @@ func New(namespace string) *Metrics { Name: "validator_delegator_shares", Help: "Validator delegator shares", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUnbondingTime: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -341,7 +341,7 @@ func New(namespace string) *Metrics { Name: "validator_unbonding_time", Help: "Validator unbonding time", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorMinSelfDelegation: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -349,7 +349,7 @@ func New(namespace string) *Metrics { Name: "validator_min_self_delegation", Help: "Validator min self delegation", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorParticipationRate: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -357,7 +357,7 @@ func New(namespace string) *Metrics { Name: "validator_participation_rate", Help: "Validator participation rate", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorParticipationTotal: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -365,7 +365,7 @@ func New(namespace string) *Metrics { Name: "validator_participation_total", Help: "Validator participation total", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorSigningInfo: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -373,7 +373,7 @@ func New(namespace string) *Metrics { Name: "validator_signing_info", Help: "Validator signing info", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptime: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -381,7 +381,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime", Help: "Validator uptime", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorVotingPowerPercent: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -389,7 +389,7 @@ func New(namespace string) *Metrics { Name: "validator_voting_power_percent", Help: "Validator voting power percent", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorCumulativeShare: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -397,7 +397,7 @@ func New(namespace string) *Metrics { Name: "validator_cumulative_share", Help: "Validator cumulative share", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorParticipationVoted: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -405,7 +405,7 @@ func New(namespace string) *Metrics { Name: "validator_participation_voted", Help: "Validator participation voted", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorSigningInfoBondedHeight: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -413,7 +413,7 @@ func New(namespace string) *Metrics { Name: "validator_signing_info_bonded_height", Help: "Validator signing info bonded height", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorSigningInfoTombstoned: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -421,7 +421,7 @@ func New(namespace string) *Metrics { Name: "validator_signing_info_tombstoned", Help: "Validator signing info tombstoned", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeHistoricalEarliestHeight: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -429,7 +429,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_historical_earliest_height", Help: "Validator uptime historical earliest height", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeHistoricalLastSyncHeight: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -437,7 +437,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_historical_last_sync_height", Help: "Validator uptime historical last sync height", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeHistoricalSuccessBlocks: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -445,7 +445,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_historical_success_blocks", Help: "Validator uptime historical success blocks", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeWindowUptime: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -453,7 +453,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_window_uptime", Help: "Validator uptime window uptime", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeWindowStart: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -461,7 +461,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_window_start", Help: "Validator uptime window start", }, - []string{"address"}, + []string{"address", "name"}, ), ValidatorUptimeWindowEnd: prometheus.NewGaugeVec( prometheus.GaugeOpts{ @@ -469,7 +469,7 @@ func New(namespace string) *Metrics { Name: "validator_uptime_window_end", Help: "Validator uptime window end", }, - []string{"address"}, + []string{"address", "name"}, ), } diff --git a/pkg/watcher/validators_api.go b/pkg/watcher/validators_api.go index bbeb8fd..b1aebe5 100644 --- a/pkg/watcher/validators_api.go +++ b/pkg/watcher/validators_api.go @@ -127,11 +127,11 @@ func (w *ValidatorsAPIWatcher) fetchAccount(ctx context.Context, validator Track log.Debug().Interface("account", account).Str("validator", validator.Account).Msg("fetched account info") // update metrics - w.metrics.ValidatorBalanceAvailable.WithLabelValues(validator.Address).Set(float64(account.Balance.Available)) - w.metrics.ValidatorCommission.WithLabelValues(validator.Address).Set(float64(account.Balance.Commission)) - w.metrics.ValidatorBalanceDelegated.WithLabelValues(validator.Address).Set(float64(account.Balance.Delegated)) - w.metrics.ValidatorBalanceReward.WithLabelValues(validator.Address).Set(float64(account.Balance.Reward)) - w.metrics.ValidatorBalanceUnBonding.WithLabelValues(validator.Address).Set(float64(account.Balance.Unbonding)) + w.metrics.ValidatorBalanceAvailable.WithLabelValues(validator.Address, validator.Name).Set(float64(account.Balance.Available)) + w.metrics.ValidatorCommission.WithLabelValues(validator.Address, validator.Name).Set(float64(account.Balance.Commission)) + w.metrics.ValidatorBalanceDelegated.WithLabelValues(validator.Address, validator.Name).Set(float64(account.Balance.Delegated)) + w.metrics.ValidatorBalanceReward.WithLabelValues(validator.Address, validator.Name).Set(float64(account.Balance.Reward)) + w.metrics.ValidatorBalanceUnBonding.WithLabelValues(validator.Address, validator.Name).Set(float64(account.Balance.Unbonding)) return nil } @@ -218,25 +218,25 @@ func (w *ValidatorsAPIWatcher) fetchValidator(ctx context.Context, validator Tra log.Debug().Interface("validator", apiValidator).Str("validator", validator.Account).Msg("fetched validator info") // update metrics - w.metrics.ValidatorStatus.WithLabelValues(validator.Address).Set(float64(apiValidator.Status)) - w.metrics.ValidatorTokens.WithLabelValues(validator.Address).Set(float64(apiValidator.Tokens)) - w.metrics.ValidatorCommissionRate.WithLabelValues(validator.Address).Set(MustFloat64(apiValidator.Commission.CommissionRates.Rate)) - w.metrics.ValidatorDelegatorShares.WithLabelValues(validator.Address).Set(MustFloat64(apiValidator.DelegatorShares)) - w.metrics.ValidatorUnbondingTime.WithLabelValues(validator.Address).Set(float64(apiValidator.UnbondingTime.Unix())) - w.metrics.ValidatorMinSelfDelegation.WithLabelValues(validator.Address).Set(MustFloat64(apiValidator.MinSelfDelegation)) - w.metrics.ValidatorParticipationRate.WithLabelValues(validator.Address).Set(float64(apiValidator.Participation.Rate)) - w.metrics.ValidatorParticipationTotal.WithLabelValues(validator.Address).Set(float64(apiValidator.Participation.Total)) - w.metrics.ValidatorParticipationVoted.WithLabelValues(validator.Address).Set(float64(apiValidator.Participation.Voted)) - w.metrics.ValidatorSigningInfoBondedHeight.WithLabelValues(validator.Address).Set(float64(apiValidator.SigningInfo.BondedHeight)) - w.metrics.ValidatorSigningInfoTombstoned.WithLabelValues(validator.Address).Set(metrics.BoolToFloat64(apiValidator.SigningInfo.Tombstoned)) - w.metrics.ValidatorUptimeHistoricalEarliestHeight.WithLabelValues(validator.Address).Set(float64(apiValidator.Uptime.HistoricalUptime.EarliestHeight)) - w.metrics.ValidatorUptimeHistoricalLastSyncHeight.WithLabelValues(validator.Address).Set(float64(apiValidator.Uptime.HistoricalUptime.LastSyncHeight)) - w.metrics.ValidatorUptimeHistoricalSuccessBlocks.WithLabelValues(validator.Address).Set(float64(apiValidator.Uptime.HistoricalUptime.SuccessBlocks)) - w.metrics.ValidatorUptimeWindowUptime.WithLabelValues(validator.Address).Set(apiValidator.Uptime.WindowUptime.Uptime) - w.metrics.ValidatorUptimeWindowStart.WithLabelValues(validator.Address).Set(float64(apiValidator.Uptime.WindowUptime.WindowStart)) - w.metrics.ValidatorUptimeWindowEnd.WithLabelValues(validator.Address).Set(float64(apiValidator.Uptime.WindowUptime.WindowEnd)) - w.metrics.ValidatorVotingPowerPercent.WithLabelValues(validator.Address).Set(apiValidator.VotingPowerPercent) - w.metrics.ValidatorCumulativeShare.WithLabelValues(validator.Address).Set(apiValidator.CumulativeShare) + w.metrics.ValidatorStatus.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Status)) + w.metrics.ValidatorTokens.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Tokens)) + w.metrics.ValidatorCommissionRate.WithLabelValues(validator.Address, validator.Name).Set(MustFloat64(apiValidator.Commission.CommissionRates.Rate)) + w.metrics.ValidatorDelegatorShares.WithLabelValues(validator.Address, validator.Name).Set(MustFloat64(apiValidator.DelegatorShares)) + w.metrics.ValidatorUnbondingTime.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.UnbondingTime.Unix())) + w.metrics.ValidatorMinSelfDelegation.WithLabelValues(validator.Address, validator.Name).Set(MustFloat64(apiValidator.MinSelfDelegation)) + w.metrics.ValidatorParticipationRate.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Participation.Rate)) + w.metrics.ValidatorParticipationTotal.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Participation.Total)) + w.metrics.ValidatorParticipationVoted.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Participation.Voted)) + w.metrics.ValidatorSigningInfoBondedHeight.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.SigningInfo.BondedHeight)) + w.metrics.ValidatorSigningInfoTombstoned.WithLabelValues(validator.Address, validator.Name).Set(metrics.BoolToFloat64(apiValidator.SigningInfo.Tombstoned)) + w.metrics.ValidatorUptimeHistoricalEarliestHeight.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Uptime.HistoricalUptime.EarliestHeight)) + w.metrics.ValidatorUptimeHistoricalLastSyncHeight.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Uptime.HistoricalUptime.LastSyncHeight)) + w.metrics.ValidatorUptimeHistoricalSuccessBlocks.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Uptime.HistoricalUptime.SuccessBlocks)) + w.metrics.ValidatorUptimeWindowUptime.WithLabelValues(validator.Address, validator.Name).Set(apiValidator.Uptime.WindowUptime.Uptime) + w.metrics.ValidatorUptimeWindowStart.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Uptime.WindowUptime.WindowStart)) + w.metrics.ValidatorUptimeWindowEnd.WithLabelValues(validator.Address, validator.Name).Set(float64(apiValidator.Uptime.WindowUptime.WindowEnd)) + w.metrics.ValidatorVotingPowerPercent.WithLabelValues(validator.Address, validator.Name).Set(apiValidator.VotingPowerPercent) + w.metrics.ValidatorCumulativeShare.WithLabelValues(validator.Address, validator.Name).Set(apiValidator.CumulativeShare) return nil } @@ -280,7 +280,7 @@ func (w *ValidatorsAPIWatcher) fetchDelegator(ctx context.Context, validator Tra // log.Debug().Str("validator", validator.Account).Int("delegators", apiResponse.ValidatorDelegators).Msg("fetched delegator info") // update metrics - w.metrics.ValidatorDelegators.WithLabelValues(validator.Address).Set(float64(apiResponse.ValidatorDelegators)) + w.metrics.ValidatorDelegators.WithLabelValues(validator.Address, validator.Name).Set(float64(apiResponse.ValidatorDelegators)) return nil }