Observability & Accountability
How a small team answers questions about its fleet: who changed what, and which accounts look wrong.
- Role
- Sole author
- Period
- 2026
- Stack
- MongoDB · CloudWatch · WAFv2 · Fastify · React
Problem
A fleet of tenant portals produced plenty of logs, and answering a question from them meant someone reading raw streams. The questions were ordinary ones: which admin changed an account, whether a login pattern was normal, whether an error rate was real or the same benign auth failure counted a thousand times.
Constraints
This is utility customer data, which limits how long it can be kept and who can read it. The dashboard had to be usable during an incident by whoever was responding, and it had to fit the platform's existing cost budget.
Decisions
- The trail that answers 'who changed this' is kept longer than the one that answers 'who looked'.
- Benign authentication failures, account lockouts and revoked tokens are folded into an expected class, which leaves the error rate counting real failures.
- Per-pattern batch analysis replaced per-event analysis, so AI spend scales with the number of patterns.
Architecture
A wrapper records calls out to identity, mail, payment and billing providers alike, so an event exists whether the failure was ours or theirs. On the v2 capture path payloads are deep-redacted: tokens, passwords and identifiers. Measured volume is 156,656 events a day at 1.8 KB each, projected to about 35 GB at steady state.
Accountability is tiered. Admin writes record which fields changed and are kept for a year. On the v2 API, admin reads and impersonated sessions are captured too, attributed to the acting admin, and kept for ninety days.
An account-to-IP fan-out view surfaces anomalies, and an alert fires on a suspicious email-change pattern.
A composite index on tenant, environment, user and timestamp cut the sessions view 43x, and Bedrock spend is attributed to its own client in the cost dashboard so AI cost is visible next to everything else. A scheduled analyzer groups errors by code and endpoint and sends each pattern to Bedrock once, re-analyzing only when it spikes, spreads to more users or goes stale.
Outcome
- Admin writes are attributable fleet-wide; admin reads and impersonation are attributable on the v2 API.
- The error rate reflects real failures, and account anomalies have their own view.
- One composite index took the sessions view from 102 seconds to 2.4 (43x, measured live), and AI spend is attributed.