@@ -23,6 +23,7 @@ import (
2323 "github.com/obolnetwork/charon/app/health"
2424 "github.com/obolnetwork/charon/app/lifecycle"
2525 "github.com/obolnetwork/charon/app/log"
26+ "github.com/obolnetwork/charon/app/z"
2627 "github.com/obolnetwork/charon/cluster"
2728 "github.com/obolnetwork/charon/core"
2829)
@@ -45,12 +46,12 @@ var (
4546// wireMonitoringAPI constructs the monitoring API and registers it with the life cycle manager.
4647// It serves prometheus metrics, pprof profiling and the runtime enr.
4748func wireMonitoringAPI (ctx context.Context , life * lifecycle.Manager , promAddr , debugAddr string ,
48- p2pNode host.Host , eth2Cl eth2wrap.Client ,
49+ p2pNode host.Host , eth2Cl eth2wrap.Client , beaconNodeAddrs [] string ,
4950 peerIDs []peer.ID , registry * prometheus.Registry , consensusDebugger http.Handler ,
5051 pubkeys []core.PubKey , seenPubkeys <- chan core.PubKey , vapiCalls <- chan struct {},
5152 numValidators int ,
5253) {
53- beaconNodeVersionMetric (ctx , eth2Cl , clockwork .NewRealClock ())
54+ beaconNodeVersionMetric (ctx , eth2Cl , beaconNodeAddrs , clockwork .NewRealClock ())
5455
5556 mux := http .NewServeMux ()
5657
@@ -268,35 +269,37 @@ func beaconNodeSyncing(ctx context.Context, eth2Cl eth2client.NodeSyncingProvide
268269}
269270
270271// beaconNodeVersionMetric sets the beacon node version gauge.
271- func beaconNodeVersionMetric (ctx context.Context , eth2Cl eth2wrap.Client , clock clockwork.Clock ) {
272- nodeVersionTicker := clock .NewTicker (10 * time .Minute )
273-
274- setNodeVersion := func () {
275- eth2Resp , err := eth2Cl .NodeVersion (ctx , & eth2api.NodeVersionOpts {})
276- if err != nil {
277- log .Error (ctx , "Failed to fetch beacon node version. Check beacon node connectivity and API availability" , err )
278- return
279- }
280-
281- version := eth2Resp .Data
272+ func beaconNodeVersionMetric (ctx context.Context , eth2Cl eth2wrap.Client , beaconNodeAddrs []string , clk clockwork.Clock ) {
273+ nodeVersionTicker := clk .NewTicker (10 * time .Minute )
282274
275+ setNodeVersionAndID := func () {
283276 beaconNodeVersionGauge .Reset ()
284- beaconNodeVersionGauge .WithLabelValues (version ).Set (1 )
285277
286- eth2wrap .CheckBeaconNodeVersion (ctx , version )
287- }
278+ // Query each beacon node individually
279+ for _ , addr := range beaconNodeAddrs {
280+ // Get a client scoped to this specific beacon node
281+ scopedClient := eth2Cl .ClientForAddress (addr )
288282
289- setNodePeerID := func () {
290- response , err := eth2Cl . NodeIdentity ( ctx , & eth2api. NodeIdentityOpts {})
291- if err != nil {
292- log . Error ( ctx , "Failed to fetch beacon node identity. Check beacon node connectivity and API availability " , err )
293- return
294- }
283+ versionResp , err := scopedClient . NodeVersion ( ctx , & eth2api. NodeVersionOpts {})
284+ if err != nil {
285+ log . Warn ( ctx , "Failed to fetch beacon node version" , err ,
286+ z . Str ( "beacon_node_address " , addr ) )
287+ continue
288+ }
295289
296- peerID := response .Data .PeerID
290+ response , err := scopedClient .NodeIdentity (ctx , & eth2api.NodeIdentityOpts {})
291+ if err != nil {
292+ log .Warn (ctx , "Failed to fetch beacon node identity" , err ,
293+ z .Str ("beacon_node_address" , addr ))
294+ continue
295+ }
296+
297+ version := versionResp .Data
298+ beaconID := response .Data .PeerID
299+ beaconNodeVersionGauge .WithLabelValues (version , beaconID ).Set (1 )
297300
298- beaconNodePeerIDGauge . Reset ( )
299- beaconNodePeerIDGauge . WithLabelValues ( peerID ). Set ( 1 )
301+ eth2wrap . CheckBeaconNodeVersion ( ctx , version )
302+ }
300303 }
301304
302305 go func () {
@@ -306,11 +309,9 @@ func beaconNodeVersionMetric(ctx context.Context, eth2Cl eth2wrap.Client, clock
306309 for {
307310 select {
308311 case <- onStartup :
309- setNodeVersion ()
310- setNodePeerID ()
312+ setNodeVersionAndID ()
311313 case <- nodeVersionTicker .Chan ():
312- setNodeVersion ()
313- setNodePeerID ()
314+ setNodeVersionAndID ()
314315 case <- ctx .Done ():
315316 return
316317 }
0 commit comments