fix(evaluate): a region without results no longer keeps a monitor up
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / test (pull_request) Successful in 9m3s
ci / lint (pull_request) Successful in 10m9s
ci / build (pull_request) Successful in 9m54s
ci / image (pull_request) Successful in 3m16s

A monitor went down only when every assigned region had failed and
reported recently, so one region whose checkers were gone kept a monitor
up for good, even while all other regions reported its target failing.
Regions without recent results are now left out: a monitor goes down
when every region that reported recently has failed. One region failing
while another succeeds still does not alert, and with every region
silent nothing is judged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-24 23:43:02 +01:00
1 parent 4d03a86614
commit 2054660625
5 files changed
+38 -16

No files matched your search

+13 -6
View File
@@ -1,9 +1,11 @@
// Package evaluate turns per-region check results into a monitor state.
//
// A monitor goes down only when every region it is assigned to has failed
// the configured number of times in a row and reported recently. A region
// without recent results counts as unknown and keeps the monitor up: one
// checker losing its network must not page anyone. Any successful region
// A monitor goes down when every region it is assigned to that reported
// recently has failed the configured number of times in a row: one region
// failing while another succeeds is the checker's problem, not the
// target's. A region without recent results counts as unknown and is left
// out, so a dead region neither keeps a monitor up nor takes it down; with
// every region unknown nothing is judged at all. Any successful region
// brings the monitor back up.
//
// The state lives in Redis and each observation is applied by one Lua
@@ -86,12 +88,17 @@ if state == 'down' then
end
return 'none'
end
local reporting = 0
for i = 7, #ARGV do
local r = ARGV[i]
local fails = tonumber(redis.call('HGET', key, 'f:' .. r) or '0')
local seen = tonumber(redis.call('HGET', key, 'a:' .. r) or '0')
if fails < need or seen < stale then return 'none' end
if seen >= stale then
local fails = tonumber(redis.call('HGET', key, 'f:' .. r) or '0')
if fails < need then return 'none' end
reporting = reporting + 1
end
end
if reporting == 0 then return 'none' end
redis.call('HSET', key, 'state', 'down')
return 'down'
`)