Skip to content

Commit b30d6d4

Browse files
authored
app/health: add fallback beacon node usage health check (#3667)
Add health check which monitor increase in usage of fallback beacon nodes. category: feature ticket: #3328
1 parent 9026b40 commit b30d6d4

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

app/health/checks.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,19 @@ var checks = []check{
145145
return false, err
146146
}
147147

148+
return maxVal > 0, nil
149+
},
150+
},
151+
{
152+
Name: "using_fallback_beacon_nodes",
153+
Description: "Using fallback beacon nodes. Please check primary beacon nodes health.",
154+
Severity: severityWarning,
155+
Func: func(q query, _ Metadata) (bool, error) {
156+
maxVal, err := q("app_eth2_using_fallback", sumLabels(), gaugeMax)
157+
if err != nil {
158+
return false, err
159+
}
160+
148161
return maxVal > 0, nil
149162
},
150163
},

app/health/checks_internal_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,32 @@ func TestMetricsHighCardinalityCheck(t *testing.T) {
395395
})
396396
}
397397

398+
func TestUsingFallbackBeaconNodesCheck(t *testing.T) {
399+
m := Metadata{}
400+
checkName := "using_fallback_beacon_nodes"
401+
metricName := "app_eth2_using_fallback"
402+
403+
t.Run("no data", func(t *testing.T) {
404+
testCheck(t, m, checkName, false, nil)
405+
})
406+
407+
t.Run("no fallback", func(t *testing.T) {
408+
testCheck(t, m, checkName, false,
409+
genFam(metricName,
410+
genGauge(nil, 0, 0, 0),
411+
),
412+
)
413+
})
414+
415+
t.Run("single fallback", func(t *testing.T) {
416+
testCheck(t, m, checkName, true,
417+
genFam(metricName,
418+
genGauge(nil, 0, 1, 0),
419+
),
420+
)
421+
})
422+
}
423+
398424
func testCheck(t *testing.T, m Metadata, checkName string, expect bool, metrics []*pb.MetricFamily) {
399425
t.Helper()
400426

0 commit comments

Comments
 (0)