Chapter 7 · Logging & Monitoring
Revision sheet
Every lesson's idea and recap on one page. Read it before an interview, or print it.
-
7.1Logging & Monitoring Overview
Logs, metrics, and traces answer three different questions — you need all three to debug production.
- Metrics say is something wrong; logs say what; traces say where.
- Tag everything with a release id — the first triage question is always "what shipped?"
- Every incident should end by adding the signal you wished you'd had.
-
7.2Telemetry
Capture enough context to debug, sample enough to afford it, and scrub everything personal.
- Context is what makes an error actionable — breadcrumbs and release id above all.
- Scrub on the client, sample by category, send with
sendBeacon. - Keep 100% of errors; sample everything that's merely interesting.
-
7.3Alerting
Alert on user-visible symptoms with an owner and an action — everything else is noise that trains people to ignore pages.
- Symptom, threshold, window, owner, action — an alert missing any of these should be deleted.
- Rate-based metrics beat absolute counts because traffic varies.
- Alert fatigue is a bigger outage risk than missing one alert.
-
7.4Fixing
Stop the bleeding first, find the cause second — rollback beats a clever hotfix at 3am.
- Mitigate first, diagnose second — rollback is a legitimate fix.
- Source maps uploaded at build time turn noise into line numbers; never serve them publicly.
- Your incident response quality is determined by decisions made long before the incident.
Capstone
Define five alerts for an e-commerce checkout — each with a threshold, a window, an owner, and the first action on fire.