08 Observability
Status: Current Last verified: 604c95a
What the system records about itself, and what tells the owner something is wrong.
Logs
The Go services write JSON lines through src/platform/logging (time, level, msg, service, and request_id on requests); the API logs each request with its route, status, duration and client address. The Observatory logs through Python's logging with the request id. Each container keeps 3 files of 10 MB (docker compose logs, sudo ghb logs).
Backup runs log to the database too: execution_logs (30 days), shown live on the dashboard.
Metrics
| Source | Endpoint | Metrics |
|---|---|---|
| API: identity, runs, insights, notify | each service's /metrics (INTERNAL_SECRET or METRICS_TOKEN), scraped as job api with a service label | http_requests_total and http_request_duration_seconds (summary) by method, route pattern and status; app_uptime_seconds; websocket_active_connections (insights); ghb_owner_last_completed_run_timestamp_seconds (when the owner's last full backup completed, 0 for never) and ghb_owner_alert_after_seconds, from runs only; ghb_jobs by kind and state (waiting, running, dead) on the PostgreSQL queue and ghb_outbox_oldest_unpublished_seconds by producer, from the services with a job runner, measured during their passes (so they hold their last value while the database is idle); ghb_notify_deliveries_total{channel_kind,outcome} from notify: alerts sent (a digest counts once), retried, failed, held for a digest, suppressed by a rule's minimum interval or skipped (channel disabled or deleted), by slack, discord or webhook |
| Observatory | /metrics (the owner, INTERNAL_SECRET or METRICS_TOKEN) | http_requests_total, db_queries_total, app_uptime_seconds; its background jobs (ADR 0013): ghb_observatory_jobs_total{kind,outcome} (completed, failed, lost) and ghb_observatory_embedding_backlog; its LLM caps: ghb_observatory_llm_slots_total{kind,outcome} (kind chat, embedding or background; outcome acquired or busy) and ghb_observatory_llm_in_flight{kind}. Its kinds' dead jobs show in the API's ghb_jobs{kind,state} like every kind's, so JobsDead covers them |
| Caddy (self-hosted) | :2020/metrics, not published | requests and durations per host |
| The host (self-hosted) | the OpenTelemetry collector's Prometheus exporter | CPU, memory, load, paging, disks, file systems, network |
The API services and the Observatory also count ghb_legacy_internal_requests_total by route: requests still made with the deprecated INTERNAL_SECRET, which can be unset once it stops growing on all of them. Their request log names a platform service caller as actor=service:<name> (internal for the secret) and never a user. Labels use route patterns (/api/backups/:id), never ids or account data. On the VM, Prometheus scrapes all of them every 30 s and keeps 30 days (2 GB at most); Grafana's GitHub Backup dashboard shows the owner's backup age, which services answer, API traffic and latency, Caddy traffic per host and the VM's resources.
Each run's own telemetry (phase timings, decisions by reason code, archive checks, the worker's version, OS and sink) is stored with the run and shown on its dashboard page.
Product analytics
How people use the web frontends is recorded in PostHog Cloud US, only for visitors who allow it and only with NEXT_PUBLIC_POSTHOG_KEY set at build time (ANALYTICS.md, set-up in POSTHOG_SETUP.md):
| Site | Sends | Through |
|---|---|---|
| Dashboard | page views and leaves, clicks, heatmaps, web vitals, masked session replays, the event catalogue (src/lib/analytics/events.ts); sign_in_completed for GitHub from the server (posthog-node) | /ingest on its own origin, rewritten by src/proxy.ts to POSTHOG_API_HOST without cookies |
| Docs site, design site (built locally, not hosted) | the same automatic events, no custom ones, when built with the key | https://us.i.posthog.com directly (static sites) |
Events carry site; a signed-in person is identified by the account id only. Replays mask every input everywhere and all text outside the public pages; nothing is captured for /api/* or /ingest/*. No feature flag is read: the landing page's draft experiment was removed when the marketing pages became static. The services themselves send nothing to PostHog.
Alerts
| Alert | Fires when | Reaches |
|---|---|---|
Dead-man check (DEADMAN_PING_URL) | the runs service stops pinging: the owner's last full backup is older than OWNER_ALERT_AFTER (8 days), or the API is down | the owner, from the outside service (healthchecks.io or similar) |
| An account's alerts (ADR 0017) | a run of the account failed (run.failed), or its slot passed 24 hours ago without a full run (run.missed, written by the runs service's check), and a rule of the account sends that type to a channel | the account, by Slack, Discord or a signed webhook, as its rules say (/api/alerts); never by e-mail (ADR 0020) |
OwnerBackupsStale | the same age condition, for an hour | Prometheus and Grafana |
OwnerWatchMissing | the runs service answers (service="runs") but has not read the owner's last run for an hour | Prometheus and Grafana |
ServiceDown | a scrape target has not answered for 5 minutes (it names the instance) | Prometheus and Grafana |
JobsDead | a job of some kind failed its last attempt, for 15 minutes | Prometheus and Grafana |
OutboxLagging | the oldest unpublished event of an outbox has waited more than an hour, for 15 minutes | Prometheus and Grafana |
DiskAlmostFull, MemoryAlmostFull | over 85% (as df counts) or 90% for 15 minutes | Prometheus and Grafana |
The alert rules have tests (deploy/shared/testdata/alerts_test.yml, run by deploy/shared/check.sh with promtool).
The dead-man check and the accounts' own alerts notify someone; the Prometheus rules are visible, not sent. The API also logs stale owner backups as an error once a day. An alert that cannot be delivered fails its delivery and marks its channel failing, for the account to see; it does not make a dead job, so JobsDead stays the operator's.
Not in place yet
- Tracing: the collector accepts OTLP, but no service sends traces or metrics to it.
- Service level objectives: none are defined.
- A dashboard page for the accounts' alerts: the API serves them (
/api/alerts), the dashboard does not show them yet.