From 4109d4a868aa48afe9d22e76891172912b69f99c Mon Sep 17 00:00:00 2001 From: Nishant Das Date: Fri, 17 Sep 2021 19:35:12 +0800 Subject: [PATCH] Standardize Metrics To Match Minimal Metric Spec (#9623) --- beacon-chain/blockchain/metrics.go | 12 +++++++++++- beacon-chain/p2p/monitoring.go | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/beacon-chain/blockchain/metrics.go b/beacon-chain/blockchain/metrics.go index d59cd6049..f418c4771 100644 --- a/beacon-chain/blockchain/metrics.go +++ b/beacon-chain/blockchain/metrics.go @@ -63,6 +63,10 @@ var ( Name: "beacon_previous_justified_root", Help: "Previous justified root of the processed state", }) + activeValidatorCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "beacon_current_active_validators", + Help: "Current total active validators", + }) validatorsCount = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "validator_count", Help: "The total number of validators", @@ -79,6 +83,10 @@ var ( Name: "current_eth1_data_deposit_count", Help: "The current eth1 deposit count in the last processed state eth1data field.", }) + processedDepositsCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "beacon_processed_deposits_total", + Help: "Total number of deposits processed", + }) stateTrieReferences = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "field_references", Help: "The number of states a particular field is shared with.", @@ -100,7 +108,7 @@ var ( Help: "The total amount of ether, in gwei, that has been used in voting attestation head of previous epoch", }) reorgCount = promauto.NewCounter(prometheus.CounterOpts{ - Name: "beacon_reorg_total", + Name: "beacon_reorgs_total", Help: "Count the number of times beacon chain has a reorg", }) saveOrphanedAttCount = promauto.NewCounter(prometheus.CounterOpts{ @@ -194,6 +202,7 @@ func reportEpochMetrics(ctx context.Context, postState, headState state.BeaconSt activeBalance += exitingBalance + slashingBalance activeEffectiveBalance += exitingEffectiveBalance + slashingEffectiveBalance + activeValidatorCount.Set(float64(activeInstances)) validatorsCount.WithLabelValues("Pending").Set(float64(pendingInstances)) validatorsCount.WithLabelValues("Active").Set(float64(activeInstances)) validatorsCount.WithLabelValues("Exiting").Set(float64(exitingInstances)) @@ -220,6 +229,7 @@ func reportEpochMetrics(ctx context.Context, postState, headState state.BeaconSt beaconFinalizedEpoch.Set(float64(postState.FinalizedCheckpointEpoch())) beaconFinalizedRoot.Set(float64(bytesutil.ToLowInt64(postState.FinalizedCheckpoint().Root))) currentEth1DataDepositCount.Set(float64(postState.Eth1Data().DepositCount)) + processedDepositsCount.Set(float64(postState.Eth1DepositIndex() + 1)) var b *precompute.Balance var v []*precompute.Validator diff --git a/beacon-chain/p2p/monitoring.go b/beacon-chain/p2p/monitoring.go index d36e78d26..aa565ec55 100644 --- a/beacon-chain/p2p/monitoring.go +++ b/beacon-chain/p2p/monitoring.go @@ -11,6 +11,10 @@ var ( Help: "The number of peers in a given state.", }, []string{"state"}) + totalPeerCount = promauto.NewGauge(prometheus.GaugeOpts{ + Name: "libp2p_peers", + Help: "Tracks the total number of libp2p peers", + }) repeatPeerConnections = promauto.NewCounter(prometheus.CounterOpts{ Name: "p2p_repeat_attempts", Help: "The number of repeat attempts the connection handler is triggered for a peer.", @@ -42,6 +46,7 @@ var ( ) func (s *Service) updateMetrics() { + totalPeerCount.Set(float64(len(s.peers.Connected()))) p2pPeerCount.WithLabelValues("Connected").Set(float64(len(s.peers.Connected()))) p2pPeerCount.WithLabelValues("Disconnected").Set(float64(len(s.peers.Disconnected()))) p2pPeerCount.WithLabelValues("Connecting").Set(float64(len(s.peers.Connecting())))