feat(observability): Grafana infra alerts + admin email notifications (PR4) #165
Reference in New Issue
Block a user
Delete Branch "feature/email-relay-pr4"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
PR4 — Grafana infra alerts + admin email notifications (final email-relay layer)
Backend admin alerts
internal/adminalertworker: polls for player feedback + word complaints arrivingsince the last check and coalesces a burst into one digest email per interval (5 min),
to
ADMIN_EMAILfrom a distinctSMTP_RELAY_ADMIN_FROM. Inert unless both are set.separate recipients (go-mail needs a list; several operator mailboxes in one message).
feedback/gamestores gainCountSince/CountComplaintsSince.Grafana infra alerts
GF_SMTPfrom the shared relay on its STARTTLS host:port (GRAFANA_SMTP_HOST; Grafanaspeaks STARTTLS, not the backend's implicit TLS), reusing the relay creds +
SERVICE_FROM.deploy/grafana/provisioning/alerting/): a contact point →SERVICE_EMAIL, a route-all policy, and rules for scrape-target down, gatewayinternal-error rate + p99 latency, host mem/disk/CPU, Postgres connections, and TLS cert
< 20 days. Every rule is
noDataState=OKso an absent metric never false-alerts.edge_request_*,node_*,pg_*,probe_ssl_*).result="internal"is the 5xx-equivalent edge outcome.Cert-expiry
blackbox_exporterprobes the edge caddy's TLS (probe_ssl_earliest_cert_expiry)→ the cert-renewal-failure alert. Effective on prod (caddy terminates TLS on :443);
on the test contour caddy is HTTP-only, so the metric is absent and the rule no-ops.
Threshold 20 days (Caddy renews at ~30d, so 20 gives lead time to react).
Wiring & docs
ci.yaml(TEST_*),prod-deploy(PROD_*+env.sh),.env.example, README var table; ARCHITECTURE §11.TEST/PROD_{SMTP_RELAY_ADMIN_FROM, ADMIN_EMAIL, SMTP_RELAY_SERVICE_FROM, SERVICE_EMAIL, GRAFANA_SMTP_HOST, GF_SMTP_ENABLED}.Locally verified: Go build/vet/gofmt/unit (incl. adminalert), full integration package,
compose config (base + prod overlay), all new YAML parses. After the contour deploys,
worth checking
docker logs scrabble-grafanafor provisioning-load errors (Grafana skipsmalformed alerting provisioning silently) and confirming the
$__env{SERVICE_EMAIL}contactpoint resolved. This is the last layer of the email-relay feature (PR1a/1b/2/3 merged).