Files

2.9 KiB

Monitoring Setup - ASF test host

1. Logging

  • Where: stdout of the systemd user unit andreaslopfotografie-test, read with journalctl --user -u andreaslopfotografie-test -f (as gitea-workflow).
  • Levels (from shared/env): Logging__LogLevel__SlpModularCms.Website=Information on test (one line per website 301 and 404; Warning on production later); everything else keeps the committed defaults; Microsoft.EntityFrameworkCore.Database.Command stays at Warning so SQL parameters (e-mail addresses) are not logged.
  • Never logged: the setup token, passwords, tokens, full e-mail addresses. Website log lines are sanitised paths.
  • Sample lines: Website redirect 301 /Over-Mij -> /over-mij; Security event setup_token_rejected: setup token rejected on /api/v1/Setup/owner.
  • Sentry: Observability__SentryDsn (website project DSN) and Observability__Environment=test in shared/env; the admin build gets the same DSN through VITE_SENTRY_DSN_ASF and reports through /sentry-tunnel.

2. Alerting (Q4 = A), in the website's Sentry project, notification by e-mail to the project owner

Create these rules once, filtered on environment:test (the assistant did NOT create them; they change a shared Sentry project, so Bryan or the website session adds them, or asks for the sentry:sentry-create-alert skill to do it):

Rule Condition Why
Setup token rejected tag security_event:setup_token_rejected, 1+ events in 5 min someone guesses the first-admin token
Failed logins tag security_event:failed_login, 10+ in 5 min brute force on the admin
Rate limit tag security_event:rate_limit_triggered, 1+ in 5 min limiter hit; with forwarded headers this is per visitor
Migration failure tag security_event:migration_failure, 1 event host cannot start; also /health goes silent
Unhandled errors new issue in environment:test, level error or higher host or admin bug
Uptime monitor https://test.andreaslop.nl/health every 5 min if Sentry uptime is available (otherwise any external pinger) the deploy only checks once

Each alert event carries the tag via SecurityEventProcessor, so the rules survive message wording changes. The first rate_limit_triggered events also confirm whether forwarded headers work: the limiter should count real visitors, not 192.168.1.102.

3. Dashboards (Q5 = A)

None added. Use Sentry Issues filtered on environment:test, and on the Pi journalctl, systemctl --user status andreaslopfotografie-test, ls -l current.

4. Verification after the first deploy

  1. Open /doesnotexist -> journald shows a 404 line.
  2. POST a wrong X-Setup-Token to /api/v1/Setup/owner (before the first administrator exists) -> 401 and a setup_token_rejected event in Sentry with tag security_event.
  3. Stop the unit briefly -> uptime alert (if configured) and the deploy health check would fail.
  4. Check that no event contains the token or a full e-mail address.