Add beacon node count metrics. (#6371)

This commit is contained in:
Jhett Black 2024-07-06 23:07:56 +02:00 committed by GitHub
parent 0b276315d2
commit 3f051e9ab0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 21 additions and 12 deletions

View File

@ -17,6 +17,10 @@ import
const const
PREGENESIS_EPOCHS_COUNT = 1 PREGENESIS_EPOCHS_COUNT = 1
declareGauge validator_client_node_counts,
"Number of connected beacon nodes and their status",
labels = ["status"]
proc initGenesis(vc: ValidatorClientRef): Future[RestGenesis] {.async.} = proc initGenesis(vc: ValidatorClientRef): Future[RestGenesis] {.async.} =
info "Initializing genesis", nodes_count = len(vc.beaconNodes) info "Initializing genesis", nodes_count = len(vc.beaconNodes)
var nodes = vc.beaconNodes var nodes = vc.beaconNodes
@ -214,7 +218,6 @@ proc runVCSlotLoop(vc: ValidatorClientRef) {.async.} =
vc.processingDelay = Opt.some(nanoseconds(delay.nanoseconds)) vc.processingDelay = Opt.some(nanoseconds(delay.nanoseconds))
if len(vc.beaconNodes) > 1:
let let
counts = vc.getNodeCounts() counts = vc.getNodeCounts()
# Good nodes are nodes which can be used for ALL the requests. # Good nodes are nodes which can be used for ALL the requests.
@ -227,6 +230,12 @@ proc runVCSlotLoop(vc: ValidatorClientRef) {.async.} =
badNodes = counts.data[int(RestBeaconNodeStatus.Offline)] + badNodes = counts.data[int(RestBeaconNodeStatus.Offline)] +
counts.data[int(RestBeaconNodeStatus.Online)] + counts.data[int(RestBeaconNodeStatus.Online)] +
counts.data[int(RestBeaconNodeStatus.Incompatible)] counts.data[int(RestBeaconNodeStatus.Incompatible)]
validator_client_node_counts.set(int64(goodNodes), ["good"])
validator_client_node_counts.set(int64(viableNodes), ["viable"])
validator_client_node_counts.set(int64(badNodes), ["bad"])
if len(vc.beaconNodes) > 1:
info "Slot start", info "Slot start",
slot = shortLog(wallSlot), slot = shortLog(wallSlot),
epoch = shortLog(wallSlot.epoch()), epoch = shortLog(wallSlot.epoch()),