feat: multi-region evaluation, incidents and notifications (M5) #51

Merged
Sebi merged 4 commits from feat/m5-alerting into main 2026-11-22 00:46:20 +00:00
Owner

Milestone M5: multi-region evaluation, incidents and notifications. Stacked on #50 (M4).

Evaluation (#14)

  • Results are evaluated by the API as they arrive.
  • A monitor goes down only when every assigned region has failed confirmations times in a row (default 2) and reported recently. A region without results for three intervals (at least two minutes) counts as unknown and prevents the alert. Any successful region brings the monitor back up.
  • One Lua script per observation decides the transition, so concurrent results across API replicas cause a single transition. Out-of-order results are ignored.

Incidents (#15)

  • One open incident per monitor, also enforced by a partial unique index; losing the Redis state cannot create duplicates or duplicate notifications (tested).
  • The incident records the last error of each region.
  • GET /api/v1/org/incidents (incidents.read).

Notifications (#16)

  • Webhook channels: JSON payload, X-Uptimesebi-Signature: sha256=… HMAC over timestamp.body, signing secret shown once on creation and stored sealed; redirects are not followed; private addresses refused in the cloud edition.
  • Email channels via UPTIME_SMTP_URL (smtp://user:pass@host:587?from=…&tls=starttls|tls|none), localized per channel (en/de).
  • Delivery through a database outbox with leases (any replica, at-least-once) and exponential retries over ten attempts.
  • Channel CRUD and POST …/channels/:id/test (notifications.read / notifications.write).

Testing

End-to-end: a monitor in two regions against a target that fails and recovers produces exactly one incident, one signed webhook and one German mail per event.

Closes #14, #15, #16

🤖 Generated with Claude Code

https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3

Milestone M5: multi-region evaluation, incidents and notifications. Stacked on #50 (M4). ## Evaluation (#14) - Results are evaluated by the API as they arrive. - A monitor goes **down only when every assigned region** has failed `confirmations` times in a row (default 2) and reported recently. A region without results for three intervals (at least two minutes) counts as unknown and prevents the alert. Any successful region brings the monitor back up. - One Lua script per observation decides the transition, so concurrent results across API replicas cause a single transition. Out-of-order results are ignored. ## Incidents (#15) - One open incident per monitor, also enforced by a partial unique index; losing the Redis state cannot create duplicates or duplicate notifications (tested). - The incident records the last error of each region. - `GET /api/v1/org/incidents` (`incidents.read`). ## Notifications (#16) - Webhook channels: JSON payload, `X-Uptimesebi-Signature: sha256=…` HMAC over `timestamp.body`, signing secret shown once on creation and stored sealed; redirects are not followed; private addresses refused in the cloud edition. - Email channels via `UPTIME_SMTP_URL` (`smtp://user:pass@host:587?from=…&tls=starttls|tls|none`), localized per channel (en/de). - Delivery through a database outbox with leases (any replica, at-least-once) and exponential retries over ten attempts. - Channel CRUD and `POST …/channels/:id/test` (`notifications.read` / `notifications.write`). ## Testing End-to-end: a monitor in two regions against a target that fails and recovers produces exactly one incident, one signed webhook and one German mail per event. Closes #14, #15, #16 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi added this to the M5 Evaluation & Alerting milestone 2026-11-22 00:24:03 +00:00
Sebi changed target branch from feat/m4-checker to main 2026-11-22 00:45:12 +00:00
Sebi added 4 commits 2026-11-22 00:45:12 +00:00
At most one open incident per monitor is enforced by a partial unique
index.

Refs #15, #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Regions without recent results count as unknown and keep the monitor up.
State changes are decided by one Lua script so concurrent results on
several API replicas yield a single transition.

Refs #14

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Webhooks carry an HMAC-SHA256 signature over timestamp and body and
refuse private addresses unless allowed.

Refs #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Results are evaluated as they arrive. Transitions open or resolve the
monitor's incident and queue a notification per enabled channel in the
same transaction; every API replica delivers the outbox with leases and
exponential retries. Organizations manage webhook and email channels,
can send test notifications and list incidents. Email requires
UPTIME_SMTP_URL.

Closes #14
Closes #15
Closes #16

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi merged commit 53f8c063fb into main 2026-11-22 00:46:20 +00:00
Sebi deleted branch feat/m5-alerting 2026-11-22 00:46:22 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: ZB-Server/uptimesebi#51