Skip to content

Commit

Permalink
feat(issue-12348): add validator index label to validator_statuses me… (
Browse files Browse the repository at this point in the history
#14473)

* feat(issue-12348): add validator index label to validator_statuses metric

* fix: epochDuties added label on emission of metric

---------

Co-authored-by: james-prysm <[email protected]>
  • Loading branch information
0xste and james-prysm authored Nov 18, 2024
1 parent 9dbf979 commit 00aeea3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve
- Added GetAggregatedAttestationV2 endpoint.
- Added SubmitAttestationsV2 endpoint.
- Validator REST mode Electra block support
- Added validator index label to `validator_statuses` metric

### Changed

Expand Down
4 changes: 2 additions & 2 deletions validator/client/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ import (
)

var (
// ValidatorStatusesGaugeVec used to track validator statuses by public key.
// ValidatorStatusesGaugeVec used to track validator statuses by public key and validator index.
ValidatorStatusesGaugeVec = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "validator",
Name: "statuses",
Help: "validator statuses: 0 UNKNOWN, 1 DEPOSITED, 2 PENDING, 3 ACTIVE, 4 EXITING, 5 SLASHING, 6 EXITED",
},
[]string{
"pubkey",
"pubkey", "index",
},
)
// ValidatorAggSuccessVec used to count successful aggregations.
Expand Down
6 changes: 3 additions & 3 deletions validator/client/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ func (v *validator) checkAndLogValidatorStatus() bool {
}
log := log.WithFields(fields)
if v.emitAccountMetrics {
fmtKey := fmt.Sprintf("%#x", s.publicKey)
ValidatorStatusesGaugeVec.WithLabelValues(fmtKey).Set(float64(s.status.Status))
fmtKey, fmtIndex := fmt.Sprintf("%#x", s.publicKey), fmt.Sprintf("%#x", s.index)
ValidatorStatusesGaugeVec.WithLabelValues(fmtKey, fmtIndex).Set(float64(s.status.Status))
}
switch s.status.Status {
case ethpb.ValidatorStatus_UNKNOWN_STATUS:
Expand Down Expand Up @@ -970,7 +970,7 @@ func (v *validator) logDuties(slot primitives.Slot, currentEpochDuties []*ethpb.
for _, duty := range currentEpochDuties {
pubkey := fmt.Sprintf("%#x", duty.PublicKey)
if v.emitAccountMetrics {
ValidatorStatusesGaugeVec.WithLabelValues(pubkey).Set(float64(duty.Status))
ValidatorStatusesGaugeVec.WithLabelValues(pubkey, fmt.Sprintf("%#x", duty.ValidatorIndex)).Set(float64(duty.Status))
}

// Only interested in validators who are attesting/proposing.
Expand Down

0 comments on commit 00aeea3

Please sign in to comment.