Skip to content

Commit

Permalink
historical_uptime: push heartbeat counter
Browse files Browse the repository at this point in the history
Signed-off-by: bingyuyap <[email protected]>
  • Loading branch information
bingyuyap committed Feb 20, 2024
1 parent 0138d57 commit 1a4b55f
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions fly/cmd/historical_uptime/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ var (
[]string{"guardian", "chain"},
)

guardianHeartbeats = promauto.NewGaugeVec(
prometheus.GaugeOpts{
Name: "guardian_heartbeats",
Help: "Heartbeat count of each guardian on each chain over time",
},
[]string{"guardian"},
)

guardianMissedObservations = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "guardian_missed_observations_total",
Expand Down Expand Up @@ -309,20 +317,28 @@ func main() {
case <-rootCtx.Done():
return
case hb := <-heartbeatC:
for _, network := range hb.Networks {
guardianName, ok := common.GetGuardianName(hb.GuardianAddr)
if !ok {
logger.Error("guardian name not found", zap.String("guardian", hb.GuardianAddr))
continue // Skip setting the metric if guardianName is not found
}
guardianName, ok := common.GetGuardianName(hb.GuardianAddr)
if !ok {
logger.Error("guardian name not found", zap.String("guardian", hb.GuardianAddr))
continue // Skip setting the metric if guardianName is not found
}

for _, network := range hb.Networks {
guardianChainHeight.With(
prometheus.Labels{
"guardian": guardianName,
"chain": vaa.ChainID(network.Id).String(),
},
).Set(float64(network.Height))
}

guardianHeartbeats.With(
prometheus.Labels{
"guardian": guardianName,
},
).Set(float64(hb.Counter))


}
}
}()
Expand Down

0 comments on commit 1a4b55f

Please sign in to comment.