Logs & health checks
Code Lab35 min
Logs & health checks
When something breaks at 2am, logs are the story and the health check is the alarm:
- Logs are for humans — structured (
{"level":"error","msg":…}), one
event per line, no secrets.
- Health checks are for machines —
/healthreturns 200 or it doesn't;
the platform restarts what doesn't.
@Get('health')
health() { return { status: 'ok', uptime: process.uptime() }; }Observability is a feature, not an afterthought: the day you can see what the server is doing, debugging stops being archaeology.
Exercise
Add a /health endpoint to this app's backend that reports status + uptime. Then grep its logs for one real query and read it.
Practice this lesson in the IDE
Open the DevOps practice workspace, edit the starter code, and run your work in the browser.
Open IDE and practice