Skip to main content
A complete walkthrough of instrumenting a Node.js service using the popular prom-client library. See the overview for the general approach.

1. Add the dependency

2. Register custom metrics and expose /metrics

collectDefaultMetrics enables Node.js runtime metrics (event loop lag, heap size, GC duration, active handles, etc.).
For Express apps, you can mount the metrics handler directly on your main app port using express-prom-bundle — it also automatically tracks HTTP request durations, status codes, and route labels.

3. Declare the metrics endpoint in ops.json

4. Visualize with a community dashboard

To import: in Grafana, go to Dashboards → New → Import, enter the dashboard ID, and select your LocalOps Prometheus data source. You’ll instantly see heap usage, event loop lag, GC pauses, active handles, and more. Your custom application metrics (emails_sent_total, etc.) can be charted alongside.