fix(evaluate): a region without results no longer keeps a monitor up #153

Merged
Sebi merged 1 commits from fix/silent-region-no-block into main 2026-11-24 22:43:46 +00:00
5 changed files with 38 additions and 16 deletions

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@
[![ci](https://git.zb-server.de/ZB-Server/uptimesebi/actions/workflows/ci.yaml/badge.svg?branch=main)](https://git.zb-server.de/ZB-Server/uptimesebi/actions?workflow=ci.yaml) · License: AGPL-3.0-only
UptimeSebi monitors websites, APIs and services from several regions and tells you when they are down, without false alarms from a single checker losing its network: a monitor only counts as down when **every** region it is checked from fails. It publishes status pages that stay online even while UptimeSebi itself is not, and it can run entirely on your own infrastructure.
UptimeSebi monitors websites, APIs and services from several regions and tells you when they are down, without false alarms from a single checker losing its network: a monitor only counts as down when **every** region it is checked from fails. A region whose checkers are gone is left out rather than holding the monitor up, and its admins are told. It publishes status pages that stay online even while UptimeSebi itself is not, and it can run entirely on your own infrastructure.
It is built for teams and hosting providers: organizations with members, roles and SSO, run either as a shared cloud service or self-hosted.
+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'
`)
+22 -7
View File
@@ -55,9 +55,9 @@ func play(t *testing.T, e *Evaluator, now *time.Time, regions []string, confirma
func TestDownOnlyWhenAllRegionsFail(t *testing.T) {
e, now := newTest(t)
play(t, e, now, []string{"eu", "us"}, 2, []step{
{"eu", false, None},
{"eu", false, None}, // eu confirmed down, us has not reported
{"us", true, None},
{"eu", false, None},
{"eu", false, None}, // eu confirmed down, us still fine
{"us", false, None},
{"eu", false, None},
{"us", false, Down}, // both regions failed twice in a row
@@ -79,7 +79,7 @@ func TestSingleRegionWithConfirmations(t *testing.T) {
})
}
func TestSilentRegionBlocksAlert(t *testing.T) {
func TestSilentRegionIsLeftOut(t *testing.T) {
e, now := newTest(t)
id := uuid.New()
obs := func(region string, ok bool) Transition {
@@ -92,12 +92,27 @@ func TestSilentRegionBlocksAlert(t *testing.T) {
}
return got
}
obs("us", false)
// us stops reporting for longer than three intervals.
obs("us", true)
// us stops reporting for longer than three intervals: the failures of
// eu alone decide.
*now = now.Add(5 * time.Minute)
if got := obs("eu", false); got != None {
t.Errorf("eu failure with us silent = %v, want none", got)
if got := obs("eu", false); got != Down {
t.Errorf("eu failure with us silent = %v, want down", got)
}
// us reporting a success again brings the monitor back up.
*now = now.Add(time.Second)
if got := obs("us", true); got != Up {
t.Errorf("us success after the outage = %v, want up", got)
}
}
func TestReportingRegionStillVetoes(t *testing.T) {
e, now := newTest(t)
play(t, e, now, []string{"eu", "us"}, 1, []step{
{"us", true, None},
{"eu", false, None}, // us reported recently and was fine
{"eu", false, None},
})
}
func TestOutOfOrderResultIgnored(t *testing.T) {
+1 -1
View File
@@ -518,7 +518,7 @@
"email.opened.subject": "[DOWN] {{.Monitor}}",
"email.region_back.body": "Region {{.Region}} hat wieder einen aktiven Checker; seit {{.Since}} hatte sie keinen. Überfällige Prüfungen laufen sofort.\n\n{{.Link}}",
"email.region_back.subject": "Region {{.Region}} prüft wieder",
"email.region_down.body": "Region {{.Region}} hat seit {{.Minutes}} Minuten keinen aktiven Checker, seit {{.Since}}.\n\nMonitore, die nur von dort geprüft werden, werden gerade nicht geprüft: Sie fallen weder aus noch alarmieren sie. Monitore mit weiteren Regionen können nicht ausfallen, solange diese Region nichts meldet.\n\nStarte einen Checker der Region oder sieh dir seine Logs an:\n{{.Link}}",
"email.region_down.body": "Region {{.Region}} hat seit {{.Minutes}} Minuten keinen aktiven Checker, seit {{.Since}}.\n\nMonitore, die nur von dort geprüft werden, werden gerade nicht geprüft: Sie fallen weder aus noch alarmieren sie. Monitore mit weiteren Regionen werden nur nach diesen beurteilt, bis diese Region wieder meldet.\n\nStarte einen Checker der Region oder sieh dir seine Logs an:\n{{.Link}}",
"email.region_down.subject": "Region {{.Region}} hat keinen aktiven Checker",
"email.resolved.body": "{{.Monitor}} ({{.Target}}) ist nach {{.Duration}} wieder erreichbar.",
"email.resolved.subject": "[UP] {{.Monitor}}",
+1 -1
View File
@@ -518,7 +518,7 @@
"email.opened.subject": "[DOWN] {{.Monitor}}",
"email.region_back.body": "Region {{.Region}} has an active checker again; it had none since {{.Since}}. Overdue checks run right away.\n\n{{.Link}}",
"email.region_back.subject": "Region {{.Region}} is checking again",
"email.region_down.body": "Region {{.Region}} has had no active checker for {{.Minutes}} minutes, since {{.Since}}.\n\nMonitors checked only from there are not being checked right now: they neither go down nor alert. Monitors with other regions as well cannot go down while this one reports nothing.\n\nStart a checker of the region or look at its logs:\n{{.Link}}",
"email.region_down.body": "Region {{.Region}} has had no active checker for {{.Minutes}} minutes, since {{.Since}}.\n\nMonitors checked only from there are not being checked right now: they neither go down nor alert. Monitors with other regions as well are judged by those alone until this one reports again.\n\nStart a checker of the region or look at its logs:\n{{.Link}}",
"email.region_down.subject": "Region {{.Region}} has no active checker",
"email.resolved.body": "{{.Monitor}} ({{.Target}}) is reachable again after {{.Duration}}.",
"email.resolved.subject": "[UP] {{.Monitor}}",