APILensAPILens
All posts
Node.jsAPMMonitoringPerformance

Node.js APM: The Complete Guide to Application Performance Monitoring

APM tools like Datadog cost $23/host/month and take an afternoon to configure. This guide shows you what APM actually is, what to monitor in Node.js, and how to get full APM visibility in under 2 minutes.

Rahul Patel·9 min read·April 20, 2026

What Is APM (Application Performance Monitoring)?

Application Performance Monitoring (APM) is the practice of tracking, measuring, and visualizing how your application behaves in production. For a Node.js API, that means knowing:

- Which routes are slow (and exactly how slow)

- What your error rate is per endpoint

- How many database queries each request triggers

- Where time is being spent inside a request lifecycle

- How your API behaves under load over time

APM is not just logging. Logs tell you what happened. APM tells you why it happened, how often, and on which routes.


Why Traditional APM Is Too Expensive for Most Node.js Developers

The established APM market is built for enterprise teams with enterprise budgets.

ToolPricingSetup TimeAgent Required
Datadog APM$23/host/month30–60 minYes
New Relic$25/host/month20–45 minYes
Elastic APMSelf-hosted or $16/host/month1–2 hoursYes
Dynatrace$21/host/month1–2 hoursYes
APILensFree (beta)< 2 minNo

For a solo developer or small team running a Node.js API, paying $23/host/month before you've proven your product makes no sense. More importantly, the configuration overhead means most developers skip APM entirely — and fly blind in production.


What a Good Node.js APM Should Monitor

Before choosing a tool, understand what signals actually matter for a Node.js API:

Request Metrics

- Latency per route: p50, p95, p99 response times broken down by endpoint

- Request volume: requests per minute, per hour

- Error rate: percentage of 4xx and 5xx responses per route

- Status code distribution: how many 200s vs 4xx vs 5xx

Database Metrics

- Query count per request: how many DB calls does each route trigger?

- Query duration: which queries are slow?

- N+1 detection: routes that fire the same query pattern repeatedly

Infrastructure Signals

- Distributed tracing: following a request across microservices via trace IDs

- Slow endpoint alerts: notifications when p95 latency spikes

- Error rate alerts: notifications when error rate crosses a threshold

Geographic Data

- Request origin: which countries are your users coming from?

- Latency by region: are users in specific regions experiencing higher latency?


Setting Up APM in Node.js in Under 2 Minutes

Here's how to get all of the above signals in your Express or Fastify app with zero configuration.

Step 1: Install

npm install auto-api-observe

Step 2: Add one line

const express = require('express');
const { observe } = require('auto-api-observe');

const app = express();

// This single line gives you full APM
app.use(observe({ apiKey: process.env.APILENS_KEY }));

app.get('/users', async (req, res) => {
  const users = await db.query('SELECT * FROM users');
  res.json(users);
});

app.listen(3000);

The middleware automatically instruments:

- Every route's latency, status, and request count

- All database queries (pg, mysql2, mongoose, prisma, knex, sequelize, ioredis, better-sqlite3)

- Distributed trace IDs propagated via x-trace-id header

- Geographic data from request IP (IP not stored)

Step 3: Get your API key

Sign up at apilens.rest — free during beta, no credit card. Your API key is on the dashboard.


Reading Your APM Data

Once deployed, head to apilens.rest/dashboard. You'll see:

Overview tab: Total requests, error rate, average latency, and a timeline chart over the last 24h/7d.

Routes tab: Every route ranked by p95 latency. Click any route to see its full latency distribution, error rate, and DB query breakdown.

Errors tab: Every 4xx/5xx grouped by route and status code. Error rate trend over time.

Slow tab: Routes that exceeded your slow threshold (default 500ms). Configurable.

Database tab: Query counts and durations per route. N+1 patterns flagged automatically.


How Node.js APM Works Under the Hood

Most APM agents use monkey-patching: they intercept require() calls at startup and wrap core modules (http, pg, mysql, etc.) with instrumented versions. This is powerful but fragile — it's why Datadog's agent needs to be loaded before everything else with --require dd-trace/init.

auto-api-observe uses a simpler approach:

1. The Express/Fastify middleware hooks into the request lifecycle via res.on('finish')

2. DB profiling wraps the specific client methods (e.g., pg.Client.prototype.query)

3. Metrics are buffered in memory and flushed every 5 seconds via a background async batch

4. If the ingest endpoint is unreachable, metrics are dropped silently — your API never crashes because of monitoring

This design means there's no bootstrap requirement, no agent process, and minimal performance overhead (< 1ms per request in benchmarks).


Choosing a Node.js APM: Full Comparison

FeatureAPILensDatadogNew RelicPrometheus + Grafana
PriceFree (beta)$23/host/mo$25/host/moFree (self-hosted)
Setup time< 2 min30–60 min20–45 min2–4 hours
Agent requiredNoYesYesYes (exporters)
Express supportCustom
Fastify supportCustom
DB query profiling✓ AutoManual
N+1 detection
Hosted dashboardSelf-hosted
Distributed tracingWith Jaeger/Zipkin
AlertsWith Alertmanager

Choose APILens if: you want zero-config APM for a Node.js API and don't need multi-language or infrastructure monitoring.

Choose Datadog if: you're running a multi-language microservices stack and have the budget and ops team to manage it.

Choose Prometheus + Grafana if: you need full control, custom metrics, and have the infrastructure to self-host.


Practical APM Workflow for a Node.js API

Once your APM is running, here's how to actually use it:

Weekly review (10 minutes)

- Check the Routes tab: are any p95 latencies trending up?

- Check the Errors tab: any new error patterns?

- Check the Database tab: any new N+1 patterns?

After each deployment

- Watch the Overview chart for 15 minutes after deploying

- Compare error rate before and after

- Check if any routes' latency changed

When a user reports slowness

- Go to the Routes tab, find their most-used endpoints

- Check DB query count per request — N+1 is usually the cause

- Check the Slow tab for any new entries


Summary

APM doesn't have to mean a $23/host/month Datadog bill and a half-day of configuration. For Node.js APIs on Express or Fastify, you can have full production visibility — latency, errors, DB query profiling, distributed tracing, and alerts — with one npm install and one line of code.

- Install: npm install auto-api-observe

- Setup: app.use(observe({ apiKey: 'YOUR_KEY' }))

- Dashboard: apilens.rest/dashboard

- Price: Free during beta


*What APM tool are you currently using for your Node.js API? I'd love to hear what you've found works.*