A dashboard of glowing holographic charts and graphs monitoring system health
Back to Blog
DevOps
2026-02-10
3 min read

Observability: Monitoring Node.js Beyond console.log

A

Abhay Vachhani

Developer

When your app crashes on your laptop, you check the terminal. When it crashes in production, where do you look? Relying on console.log and hoping for the best is not a strategy. **Observability** is the practice of instrumenting your system so you can ask it questions and understand its internal state from the outside. But simple logs aren't enough.

1. The RED Method: Metrics that Matter

Don't just track "CPU Usage" and "Memory." Those are resource metrics, not user-impacting metrics. Use the **RED Method** for every microservice:

  • Rate: Number of requests per second. (Traffic).
  • Errors: Number of failed requests per second. (Correctness).
  • Duration: How long requests take. (p50, p90, p99 Latency).

2. Distributed Tracing with OpenTelemetry

In a microservices world, a single user request might touch 5 different services. If it's slow, which one is the culprit? **OpenTelemetry (OTel)** allows you to attach a unique Trace ID to a request and visualize its entire journey across your infrastructure.

// Manual Instrumentation with OTel
const span = tracer.startSpan('process-payment');
try {
    span.setAttribute('user.id', userId);
    await paymentService.charge(amount);
} catch (err) {
    span.recordException(err);
    span.setStatus({ code: SpanStatusCode.ERROR });
} finally {
    span.end();
}

3. Structured Logging: JSON is King

A log line like "User login failed" is useless to a machine. Use **Structured Logging** (JSON format) with libraries like **Pino**. This allows you to query your logs like a database (e.g., "Show me all logs where level=error and module=auth").

4. Alerting Philosophy: Symptoms vs Causes

Stop waking up your on-call engineer for "High CPU." High CPU is a cause, not a symptom.

  • Page on Symptoms: "Error rate is > 1%." or "Checkout latency is > 2s." (User is suffering).
  • Investigate on Causes: "Database CPU is 90%." (Check logs/dashboards during the day).

Conclusion

Building a robust system isn't just about writing code; it's about ensuring that system is operable. Start with structured logs, implement the RED method for metrics, and add tracing for distributed contexts. If you aren't monitoring it, it isn't in production.

FAQs

Why Pino instead of Winston?

Pino is significantly faster (lower overhead) because it processes logs asynchronously and focuses on JSON output by default, making it ideal for high-performance Node.js apps.

What is P99 latency?

It means 99% of your requests are faster than this number. It catches the "tail latency"—the slow outliers that frustrate your users most.