Skip to content

feat: rich HTML alert emails with host context - #45

Merged
MalteKiefer merged 2 commits into
mainfrom
feat/html-alert-email
Jul 16, 2026
Merged

MalteKiefer merged 2 commits into
mainfrom
feat/html-alert-email

Conversation

@MalteKiefer

Copy link
Copy Markdown
Owner

Fixes the "unhelpful alert email" complaint: the SMTP channel now sends a clean HTML email that names the host (not a UUID) and shows triage context. Design doc: docs/superpowers/specs/2026-07-16-html-alert-email-design.md.

Based on the security-remediation branch (#44) because it also touches notify.go/alerts.go; GitHub will retarget to main once #44 merges.

What

  • multipart/alternative email: existing plain text + new table-based, inline-styled, severity-coloured HTML.
  • Host block: hostname, IP, OS/kernel, arch·CPU·RAM, agent version, status + last-seen, uptime.
  • Optional metric block and a "View host" deep link (MON_PUBLIC_URL).
  • Other channels (Slack/Mattermost/Discord/ntfy) unchanged.

How

  • notify.Message gains optional structured fields; zero-valued by default (existing callers unaffected).
  • email_html.go renders via html/template (auto-escaping); both MIME parts base64-encoded; HTML failure falls back to plain text.
  • Enrichment at the single alerts.Engine.fire() choke point via new store.HostFactsFor (best-effort — a lookup failure still delivers the alert).

Tests

Multipart structure, hostname HTML-escaping (injection), absent-block omission, plain-text fallback. go vet/staticcheck/gosec clean; full suite green.

Preview of the rendered email: see the mockup shared during design.

Alert emails were plain text and identified the host only by UUID. The SMTP
channel now sends a multipart/alternative message: the existing plain text plus
a clean, table-based HTML body that names the host and shows facts (IP, OS/
kernel, arch/CPU/RAM, agent version, status + last-seen, uptime) and a severity-
coloured header. Slack/Mattermost/Discord/ntfy are unchanged.

- notify.Message gains optional structured fields (Host, Metric, RuleName,
  FiredAt, HostURL); all zero-valued by default so existing callers are intact.
- email_html.go renders via html/template (auto-escaping) and base64-encodes
  both MIME parts; HTML render failure falls back to plain text.
- alerts.Engine enriches at the single fire() choke point via a new
  store.HostFactsFor lookup (best-effort; failure still delivers). MON_PUBLIC_URL
  adds a deep link to the host page.
- Tests: multipart structure, hostname escaping, absent-block omission, plain
  fallback.
@MalteKiefer
MalteKiefer changed the base branch from security/audit-2026-07-16-remediation to main July 16, 2026 10:44
@MalteKiefer
MalteKiefer merged commit ec8d143 into main Jul 16, 2026
10 of 11 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