Monitoring & Logs
Logs are your app’s diary. Read it. Daily.
▶ the lesson · narrated sketch video · tap for sound
the intro
Monitoring answers “is it up?” before users tell you. Logs record what happened inside. Together: uptime checks alert you the moment the site is down, structured logs tell you why, and error tracking gives you the exact line number.
fun fact ✦
The best monitoring setup is the one that pings your phone before your users open Twitter.
the docs
the deep dive
the ideas behind the video — concepts, diagrams, a walkthrough and the traps to avoid
Your app already knows what is wrong with it. It writes it down constantly — it just writes into a void. Monitoring is the plumbing that gets that knowledge to a human: numbers for trends, events for stories, and one siren for the things worth waking you. The goal is not pretty dashboards; it is shrinking the time between it broke and here is why.
shorten the distance from broke to why
key terms
structured log
One JSON object per event, with fields like level and request ID, so machines can filter it instead of grepping prose.
{"level":"error","reqId":"a1"}metric
A number tracked over time: p95 latency, error rate, CPU. Cheap to store, perfect for graphs and alerts.
p95 latency: 120mstrace
The path of one request across services with every hop timed. Finds the slow step, not just that something is slow.
api → auth → db: 340ms totalrequest ID
An ID stamped on every log line a request produces, tying the whole story together across services.
reqId 8f3c appears 14 timeshow it works
- 1Watch from outside
An uptime monitor hits /healthz every minute from somewhere else and alerts on failure. Free tiers cover small apps entirely.
- 2Log structured, by level
JSON logs with level and request ID. Debug in dev, info for normal events, error for incidents — filterable at 3am.
- 3Track errors with stacks
An error tracker groups identical crashes, counts affected users, and shows the exact line and release. Console logs cannot.
- 4Alert a human, sparingly
Page on site-down, error spikes, and disk filling. Everything else lives on a dashboard you visit, not one that visits you.
the code, explained
structured logs beat prose at 3am
side by side
logs
- every event, full detail
- answers the why
- pricey to store at scale
- searched, shipped, grepped
metrics
- cheap numbers over time
- answers the when
- trivial to graph and alert
- no individual stories
An uptime check that pings your homepage can be green all night while the app is dead — CDN caches are that good. Point the check at a cheap endpoint that actually touches the database, like /healthz.
quick answers
My logs are huge — what do I keep?
That is what levels are for: keep error and warn long, sample or shorten info, and leave debug out of prod unless you can switch it on per-request.
What should I actually alert on?
Only things that need a human tonight: site down, error rate spiking, disk near full. Everything else belongs on a dashboard, not in your pocket.
An error tracker or just logs?
Both. The tracker groups identical crashes, dedupes them, counts affected users, and shows the release and line; logs tell you what happened around it.
quick hits about Monitoring & Logs
short answers · interviews, tips, trivia & hidden gems