Skip to content

alerts: declarative rules via config; drop in-repo chart#55

Merged
thejefflarson merged 1 commit into
mainfrom
alert-email
Jun 21, 2026
Merged

alerts: declarative rules via config; drop in-repo chart#55
thejefflarson merged 1 commit into
mainfrom
alert-email

Conversation

@thejefflarson

Copy link
Copy Markdown
Owner

Alert rules become declarative: a JSON config (WATCHER_ALERTS_CONFIG, rendered from the chart's server.alerts values) is the source of truth, reconciled into alert_rules on startup. The /api/alerts surface is now read-only.

Server

  • alerts.rs: RuleConfig (serde + defaults), load_rules(path), validate (same enum whitelist the old create API used), and reconcile(pool, rules) — validate-all → upsert each by name (preserving id + event history) → prune anything no longer declared, in one transaction.
  • main.rs: on startup, load + reconcile from WATCHER_ALERTS_CONFIG; a bad config is logged, not fatal (prior rules stand, ingest unaffected).
  • migrations/0012: unique index on alert_rules.name for the upsert (dedups legacy rows first).
  • Read-only API/UI: dropped POST/DELETE /api/alerts, their handlers, NewAlertRule, the UI create form + delete button, and createAlert/deleteAlert.

Chart removed from this repo

The Helm chart lives only in the cluster GitOps repo now, so this drops the stale in-repo chart/, its CI helm lint job + build dependency, and the chart references in the docs. The ConfigMap/mount/env wiring lands in the cluster repo.

Tests

Converted the alert integration tests to drive the real reconcile path; added coverage for config defaults, validation, empty-config pruning, and in-place upsert. 16 unit + 35 integration tests green.

Merging to main triggers the image build → ArgoCD Image Updater pins the new digest and rolls it.

🤖 Generated with Claude Code

Alert rules become declarative: a JSON config (WATCHER_ALERTS_CONFIG,
rendered from the chart's server.alerts values) is the source of truth,
reconciled into alert_rules on startup. reconcile() validates all rules,
upserts each by name (preserving id + event history), and prunes any rule
no longer declared. The /api/alerts surface is now read-only (dropped the
create/delete routes, handlers, and UI form); migration 0012 adds the
unique name index the upsert needs.

The Helm chart now lives only in the ../cluster GitOps repo, so remove the
stale in-repo chart/, its CI helm-lint job and build dependency, and the
chart references in the docs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JbrmfzHsTMMzPaSrUkZgWo
@thejefflarson thejefflarson merged commit 78c6141 into main Jun 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant