From eb0d4aa432fa9c57426c6b8275a3a80d147aa5c9 Mon Sep 17 00:00:00 2001 From: 0xste <16362825+0xste@users.noreply.github.com> Date: Tue, 24 Sep 2024 12:06:31 +0100 Subject: [PATCH] feat(issue-12348): add validator index label to validator_statuses metric --- CHANGELOG.md | 1 + validator/client/metrics.go | 4 ++-- validator/client/validator.go | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd6fde78f1dc..6b63805ef995 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ The format is based on Keep a Changelog, and this project adheres to Semantic Ve - Updated k8s-io/client-go to v0.30.4 and k8s-io/apimachinery to v0.30.4 - Migrated tracing library from opencensus to opentelemetry for both the beacon node and validator. - Refactored light client code to make it more readable and make future PRs easier. +- Added validator index label to `validator_statuses` metric ### Deprecated - `--disable-grpc-gateway` flag is deprecated due to grpc gateway removal. diff --git a/validator/client/metrics.go b/validator/client/metrics.go index d8ea5f91e852..7d17dfe44ec2 100644 --- a/validator/client/metrics.go +++ b/validator/client/metrics.go @@ -16,7 +16,7 @@ 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", @@ -24,7 +24,7 @@ var ( 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. diff --git a/validator/client/validator.go b/validator/client/validator.go index d6eca9ae6fee..39b589fc6aa3 100644 --- a/validator/client/validator.go +++ b/validator/client/validator.go @@ -362,8 +362,8 @@ func (v *validator) checkAndLogValidatorStatus(activeValCount int64) 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: