observability: KSE-0191 total observability v2 — generated dashboards, OpenTofu alerting, fleet agent, collectors, API tracing #163
No reviewers
Labels
No labels
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
key-store/key.store!163
Loading…
Reference in a new issue
No description provided.
Delete branch "claude/total-observability-v2"
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?
Implements KSE-0191 — Total Observability v2 (
evolution/proposals/KSE-0191-total-observability-v2-grafana-as-code.md): every signal, every machine, every dollar, one Grafana as code. Founder direction 2026-08-18: "make our grafana and logging/reporting ultra complete… use opentofu to make dashboards".What lands
Grafana as code (OpenTofu,
infra/grafana)services/grafana/src, ~700 panels);bun services/grafana/src/generate.ts+ CI gateScripts/grafana-dashboards-check.sh; the stack readsservices/grafana/dashboards/manifest.json— adding a dashboard is one TS file, zero HCL.alerts.tf: fleet, API SLO burn, data plane, PostHog, identity/security, CI, business) + the org home dashboard. The root policy and contact point stay Nix file-provisioned (alerting.dispatcher.routeAll, landed on main in parallel) — this stack is additive. Dashboards bind datasources by name (hiddenDS_*variables), alert rules resolve them by name.Fleet & forge (Nix)
services."key.store".observabilityAgentmodule (Grafana Alloy): host metrics, journald (levellabel), local OTLP → forge via the authenticated ingest. HQ enabled (it was completely dark) +hq-watchdog→ textfile metrics.traces.key.storebecomes the authenticated fleet ingest (Caddybasic_auth, principalshq/staging/api, hashes rendered from age secrets into/run/caddy/security.env; PENDING/missing → unsatisfiable hash, never an empty account). It was an unauthenticated public OTLP gRPC ingress before.otlp(behind Caddy) +otlp/local; PII-scrubbingattributesprocessor (ips, user ids, UAs, auth headers, query strings;db.statementhashed),transform/normalizeforhttp.route/status, spanmetrics with exemplars, OTLP logs → Loki/otlp, OTLP metrics → Prometheus remote-write (validated withotelcol-contrib validate).{{.Comm}}from 5,878 cgroup ids), blackbox (HTTPS probes + TLS expiry for every public hostname incl. relay.oblivious.network), postgres, redis ×3, smartctl, Caddy (metricsglobal), otelcol, Loki, Tempo, Grafana (via local Host-header proxy), Authentik server :9300, PostHog capture, ClickHouse (prometheusblock :9363), Kafka JMX (jmx_prometheus_httpserver :7071) + consumer-group lag textfile, forgejo-ci-exporter :9570.key-store-*uids (follows main's scheme, always-delete re-key), Tempo↔Loki↔Prometheus correlations, dead Jaeger entry removed, PostHog ClickHouse datasource (read-only,posthogdb) + plugin; file-provisioned dashboards removed (OpenTofu owns them now). Loki:levellabel from priority, Caddy JSON access logs re-labelledjob=caddy-access.rulesin Nix retired (they had no Alertmanager).Collectors (
services/observability/*.cjs, systemd timers → node_exporter textfile)forgejo-ci-exporter(Forgejo Postgres → runs/jobs/runners/durations/queue wait/last status, 1.4k series in 154 ms live),store-analytics(ASC sales + analytics reports + TestFlight + reviews, Play stats bucket + Reporting API vitals, Chrome Web Store listing, AMO, Flathub, Microsoft Store, GitHub, Homebrew → Prometheus counters/gauges and PostHogstore_daily_metricsevents),spend-and-cash(Anthropic + OpenAI admin cost/usage APIs, Mercury, Base USDC, beancount, Hetzner cloud, PlanetScale invoices, fixed contracts → spend/tokens/cash/runway),planetscale-org-exporter,posthog-health-exporter(readyz, capture liveness, ClickHouse ingest lag),kafka-consumer-lag-textfile.sh,hq-watchdog-textfile.sh. All degrade per-source; live read-only runs on the forge verified each.API / Fly edge
METHOD /routewithhttp.route/http.status_code(the spanmetrics dimensions — RED per route finally works), W3C trace-context extraction (Fly edge Caddy span → API span → dependencies),/v1/telemetry/otlp/{traces,logs}behind the OHTTP trust header (anonymized client traces/logs travel the same relay path as analytics; ≤1 MiB; collector scrubs), Caddytracing(servicekey.store-api-edge) +metricson :9091 ([metrics]in fly.toml → Fly org Prometheus), entrypoint derivesOTEL_EXPORTER_OTLP_HEADERSfromKEY_STORE_TELEMETRY_INGEST_{USER,PASSWORD}, deploy-api optional (lenient while PENDING) secret.cargo check/cargo test(59 pass), rustfmt.Validation
tofu validate+ live read-onlyplanagainst graphs.key.store (38 to add, datasource lookups resolved);alloy validateon the rendered HQ config;otelcol-contrib validate;caddy validateon the forge ingest vhost and the Fly Caddyfile;nix evalofkeystore-forgeandkeystore-hq(pre-rebase — see note); generator self-validates (unique uids, non-overlapping grid, datasource refs).Post-rebase check (on the forge, branch head
4ee20377):nix evalofkeystore-forgeandkeystore-hqsucceeds andtofu validateis green after re-merging the Grafana module on top of main's concurrent policy/forge-health/uid changes.Go-live order (details:
services/observability/graphs-on-forge.md)deploy-apiships the new API automatically.deploy-forge-host(switch).Scripts/grafana-tofu-adopt.sh(imports the pre-existingkey-storefolder) →cloud-tofustackgrafanaplan/apply →Scripts/grafana-tofu-adopt.sh --retire(deletes the 3 superseded hand-written dashboards).secrets/observability/ingest-password-hq.ageis real.Founder steps (secrets created as
PENDINGplaceholders; nothing was decrypted or rekeyed)secrets/observability/ingest-password-{hq,api,staging}.age(openssl rand -base64 36;apiis picked up by deploy-api, until then the API exports OTLP unauthenticated and the forge answers 401),secrets/anthropic/admin-api-key.age(Admin API key, usage/cost scope),secrets/openai/admin-api-key.age(org admin key),secrets/observability/mercury-api-token.age(read-only twin of the finance token, forge-readable),/etc/key-store/{store-analytics,spend-and-cash}.envon the forge (ASC vendor number, Play reports bucket, CWS/AMO/Flathub ids, Base addresses, fixed vendor contracts) — the dashboards show exactly which item is missing.Not in this PR (KSE-0191 Phase B): client-side OTEL exporters in the Swift core/Web (the endpoints and scrubbing are ready), relay-origin attestation at the edge.
🤖 Generated with Claude Code
- TraceLayer: spans named METHOD /route with http.route/http.status_code (what the forge spanmetrics connector keys RED metrics on), W3C parent extraction so the Fly edge Caddy span parents the API span - /v1/telemetry/otlp/{traces,logs}: OHTTP-trust-gated forwarding of client OTLP (≤1 MiB, protobuf/json) to the forge collector with the api ingest credential — anonymized client traces/logs ride the same relay path as analytics - Fly edge: Caddy tracing (service key.store-api-edge) + metrics on :9091 ([metrics] in fly.toml); entrypoint derives OTEL_EXPORTER_OTLP_HEADERS from KEY_STORE_TELEMETRY_INGEST_{USER,PASSWORD} - deploy-api: optional (lenient while PENDING) KEY_STORE_TELEMETRY_INGEST_PASSWORD Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>c954ef2686a8900a629ba8900a629b6d42839169