feat(monitor): save state changes for group monitors #158

Merged
lerko merged 2 commits from feat/group-state-history into main 2026-06-28 15:20:30 +00:00
Owner

Backlog item #12j — group state history.

Changes

checkGroup() now detects status transitions and persists state change records, matching the behavior of individual monitors. Previously, groups only updated in-memory liveState via applyState() without saving transitions — meaning History, SLA, and the detail panel's state change list were always empty for groups.

Now when a group transitions (e.g. UP→DOWN because a child went down):

  • A writeStateChange is enqueued to persist the transition
  • StatusChangedAt is updated on the live state
  • A log entry is emitted ("Group 'X' is DOWN" / "Group 'X' recovered")

No change to how group status is computed — still aggregated from children using worst-status-wins logic.

Test plan

  • go build ./... — clean
  • go test ./... — all pass
  • golangci-lint run ./... — 0 issues
  • 3 new tests: TestCheckGroup_SavesStateChange, TestCheckGroup_NoChangeNoWrite, TestCheckGroup_RecoveryLog
  • All 6 existing TestCheckGroup_* tests still pass
Backlog item #12j — group state history. ## Changes `checkGroup()` now detects status transitions and persists state change records, matching the behavior of individual monitors. Previously, groups only updated in-memory `liveState` via `applyState()` without saving transitions — meaning History, SLA, and the detail panel's state change list were always empty for groups. Now when a group transitions (e.g. UP→DOWN because a child went down): - A `writeStateChange` is enqueued to persist the transition - `StatusChangedAt` is updated on the live state - A log entry is emitted ("Group 'X' is DOWN" / "Group 'X' recovered") No change to how group status is computed — still aggregated from children using worst-status-wins logic. ## Test plan - [x] `go build ./...` — clean - [x] `go test ./...` — all pass - [x] `golangci-lint run ./...` — 0 issues - [x] 3 new tests: `TestCheckGroup_SavesStateChange`, `TestCheckGroup_NoChangeNoWrite`, `TestCheckGroup_RecoveryLog` - [x] All 6 existing `TestCheckGroup_*` tests still pass
lerko added 1 commit 2026-06-28 15:00:41 +00:00
feat(monitor): save state changes for group monitors
CI / test (pull_request) Successful in 1m57s
CI / lint (pull_request) Successful in 1m11s
CI / vulncheck (pull_request) Successful in 56s
25f4b20b87
checkGroup() now detects status transitions and persists them as
state change records, same as individual monitors. Groups also
get StatusChangedAt updates and log entries for down/recovery
events. This enables history and SLA views for group monitors.
lerko added 1 commit 2026-06-28 15:15:42 +00:00
fix(monitor): refresh maintenance cache after loading sites
CI / test (pull_request) Successful in 1m49s
CI / lint (pull_request) Successful in 1m17s
CI / vulncheck (pull_request) Successful in 56s
ab1194f74d
Move refreshMaintenanceCache() to after sites are loaded into
liveState. Previously it ran before the site loading loop, so on
the first iteration liveState was empty and the cache resolved
to nothing. This caused groups to briefly show DOWN on startup
for children that were in maintenance, until the next poll cycle
repopulated the cache.
lerko merged commit ab1194f74d into main 2026-06-28 15:20:30 +00:00
lerko deleted branch feat/group-state-history 2026-06-28 15:20:30 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: lerkolabs/uptop#158