How to Monitor a Production Node.js App with Health Checks and Metrics
Monitoring means continuously watching your Node.js app's health and performance, so you learn about problems from your dashboards — not from angry users. Good monitoring rests on three things: health checks, metrics, and alerts.
1. Health checks
Expose a simple endpoint (like /health) that returns OK when the app and its critical dependencies are working. Load balancers and uptime monitors hit it to know whether an instance is healthy, and to route around one that is not.
app.get('/health', (req, res) => res.json({ status: 'ok' }));
2. Metrics worth tracking
- Event-loop lag — rising lag means you are blocking the event loop.
- Memory usage — a steady climb signals a memory leak.
- Response times and error rates — the direct measure of user experience.
- CPU and request throughput — to know when to scale.
3. Alerts
Set alerts on the things that matter — high error rate, slow responses, the app being down, memory near its limit — so you are notified the moment thresholds are crossed. An alert that arrives before users complain is the whole goal.
Tools
PM2 gives quick process stats (pm2 monit), external uptime monitors watch your health endpoint, and full application-monitoring services track metrics and traces over time. Pair these with solid structured logging. On a VPS, also watch the server itself — see monitoring server load.
Frequently asked questions
What's the single most useful thing to monitor?
Start with uptime plus error rate and response time via a health check — they tell you fastest whether users are affected. Add memory and event-loop lag to catch the classic Node problems early.
What should a health check verify?
At minimum that the app responds; ideally that critical dependencies (database, cache) are reachable too. Keep it lightweight so frequent checks do not add load.
How do I get alerted about crashes?
Combine an uptime monitor on your health endpoint with your process manager's restart logs and an alerting integration, so a crash or downtime notifies you immediately.
Was this article helpful?