feat: show unchecked monitors and tell about regions without checkers
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 6m17s
ci / test (pull_request) Successful in 12m7s
ci / build (pull_request) Successful in 19m34s
ci / image (pull_request) Successful in 3m15s

A region whose checkers had all gone left its monitors looking up: the
console and status pages took the last result, however old, and nobody
was told.

- A region's last result counts only while it is younger than the
  evaluator's staleness (3 intervals, at least 2 minutes); older ones
  show as "no data since …" in the console and leave status page
  components unknown instead of operational.
- A monitor no region has reported for recently is marked "not being
  checked", counted on the dashboard with an explanation, and noted on
  its page.
- A region watch on every API replica emails the platform's admins
  (platform regions) or the organization's owners (own regions) once a
  region with checkers and enabled monitors has had no live checker for
  UPTIME_REGION_ALERT_AFTER (default 5m), and again when one is back.
  The dashboard names such regions at once.

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:35:43 +01:00
1 parent f3d0a4c844
commit dc2e21f964
18 files changed
+3272 -2652

No files matched your search

+29 -1
View File
@@ -21,6 +21,7 @@ import (
"git.zb-server.de/ZB-Server/uptimesebi/internal/auth"
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
"git.zb-server.de/ZB-Server/uptimesebi/internal/check"
"git.zb-server.de/ZB-Server/uptimesebi/internal/evaluate"
"git.zb-server.de/ZB-Server/uptimesebi/internal/i18n"
"git.zb-server.de/ZB-Server/uptimesebi/internal/maintenance"
"git.zb-server.de/ZB-Server/uptimesebi/internal/notify"
@@ -91,7 +92,14 @@ func (s *Server) dashboard(c *gin.Context) {
v.Ranges = rangeOptions(c, data.rng, earliest, data.now)
for _, m := range data.rows {
v.Counts[m.Status]++
if m.Unchecked {
v.Unchecked++
}
}
for id, since := range s.regionsWithoutChecker(c.Request.Context(), data.usedRegions) {
v.DeadRegions = append(v.DeadRegions, web.DeadRegion{Name: data.regionOf[id].Name, Since: since.Local().Format("2006-01-02 15:04")})
}
slices.SortFunc(v.DeadRegions, func(a, b web.DeadRegion) int { return strings.Compare(a.Name, b.Name) })
}
web.Render(c, http.StatusOK, web.Dashboard(s.pageFor(c, "console.monitors.title"), me, v))
}
@@ -214,6 +222,8 @@ type monitorData struct {
firstRegion map[uuid.UUID]map[string]time.Time
// statuses are the organization's own incident statuses.
statuses customStatuses
// usedRegions are the regions the enabled monitors are checked from.
usedRegions []uuid.UUID
}
// loadFirstData finds when monitors and their regions first reported. The
@@ -366,6 +376,13 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
for _, a := range assigned {
regionsOf[a.MonitorID] = append(regionsOf[a.MonitorID], a.RegionID)
}
for _, m := range monitors {
if m.Enabled {
d.usedRegions = append(d.usedRegions, regionsOf[m.ID]...)
}
}
slices.SortFunc(d.usedRegions, func(a, b uuid.UUID) int { return strings.Compare(a.String(), b.String()) })
d.usedRegions = slices.Compact(d.usedRegions)
latestOf := map[uuid.UUID]map[string]store.LatestResultsRow{}
for _, l := range latest {
if latestOf[l.MonitorID] == nil {
@@ -393,9 +410,18 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
}
var latencies []int32
failing, reported := 0, 0
// A region that has not reported for longer than the evaluator
// waits is unknown, whatever its last result said; passive monitors
// judge their own lateness.
staleBefore := now.Add(-evaluate.StaleAfter(time.Duration(m.IntervalSeconds) * time.Second))
for _, key := range keys {
rs := web.RegionStatus{Name: d.regionNameString(key), Status: web.StatusUnknown, Detail: "–"}
if l, ok := latestOf[m.ID][key]; ok {
l, ok := latestOf[m.ID][key]
if ok && !check.Passive(check.Type(m.Type)) && l.Time.Before(staleBefore) {
rs.Detail = i18n.T(ctx, "monitors.no_data_since", "Time", l.Time.Format("15:04"))
ok = false
}
if ok {
reported++
rs.Detail = l.Time.Format("15:04:05")
if l.Ok {
@@ -421,6 +447,8 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
row.Status = web.StatusDown
case reported == 0:
row.Status = web.StatusUnknown
// Nobody is checking it, unless it is too new to have results.
row.Unchecked = !check.Passive(check.Type(m.Type)) && m.CreatedAt.Before(staleBefore)
case failing > 0:
row.Status = web.StatusDegraded
default: