Skip to content

Commit 1a4b55f

Browse files
committed
historical_uptime: push heartbeat counter
Signed-off-by: bingyuyap <bingyu.yap.21@gmail.com>
1 parent 0138d57 commit 1a4b55f

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

fly/cmd/historical_uptime/main.go

+22-6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ var (
5959
[]string{"guardian", "chain"},
6060
)
6161

62+
guardianHeartbeats = promauto.NewGaugeVec(
63+
prometheus.GaugeOpts{
64+
Name: "guardian_heartbeats",
65+
Help: "Heartbeat count of each guardian on each chain over time",
66+
},
67+
[]string{"guardian"},
68+
)
69+
6270
guardianMissedObservations = promauto.NewCounterVec(
6371
prometheus.CounterOpts{
6472
Name: "guardian_missed_observations_total",
@@ -309,20 +317,28 @@ func main() {
309317
case <-rootCtx.Done():
310318
return
311319
case hb := <-heartbeatC:
312-
for _, network := range hb.Networks {
313-
guardianName, ok := common.GetGuardianName(hb.GuardianAddr)
314-
if !ok {
315-
logger.Error("guardian name not found", zap.String("guardian", hb.GuardianAddr))
316-
continue // Skip setting the metric if guardianName is not found
317-
}
320+
guardianName, ok := common.GetGuardianName(hb.GuardianAddr)
321+
if !ok {
322+
logger.Error("guardian name not found", zap.String("guardian", hb.GuardianAddr))
323+
continue // Skip setting the metric if guardianName is not found
324+
}
318325

326+
for _, network := range hb.Networks {
319327
guardianChainHeight.With(
320328
prometheus.Labels{
321329
"guardian": guardianName,
322330
"chain": vaa.ChainID(network.Id).String(),
323331
},
324332
).Set(float64(network.Height))
325333
}
334+
335+
guardianHeartbeats.With(
336+
prometheus.Labels{
337+
"guardian": guardianName,
338+
},
339+
).Set(float64(hb.Counter))
340+
341+
326342
}
327343
}
328344
}()

0 commit comments

Comments
 (0)