TopGit
GitHub Repo Review

Prometheus client_js: Node Metrics Client Review

prometheus/client_js
PTopGit review image for prometheus/client_js
Review by Topgit.dev for prometheus/client_js, with GitHub repository stats and README context.
Quick verdict

Use `@prometheus-io/client` to instrument a Node.js service whose metrics will be scraped in Prometheus/OpenMetrics format; skip it if you expect an all-in-one monitoring server or a bundled HTTP endpoint. Checked against v0.16.1 on 2026-11-15; Apache-2.0; its declared Node range is `^22 || ^24 || >=26`; the latest release is dated 2026-08-27 and an export proposal was opened 2026-11-15. [S2–S5, S7]

Stars
★ 3.5k
Forks
⑂ 436
Language
JavaScript
License
Apache-2.0
Topic
Developer Tools
Updated
Nov 2026
Homepage
—
GitHub

Understanding the Prometheus Node.js Client

`@prometheus-io/client` is an instrumentation library, not the Prometheus server: create metrics, collect values, and serve `await registry.metrics()` from a route in your own HTTP application. The README explicitly says no web framework is bundled. The documented installation command is `npm install @prometheus-io/client`. [S2]

Core Features for Node.js Application Monitoring

  • ✓Create Counter, Gauge, Histogram, and Summary metrics for Prometheus/OpenMetrics exposition. [S2]
  • ✓Collect default Node.js process metrics through the registry. [S2]
  • ✓Expose registry output using `await registry.metrics()` from an application-owned route. [S2]
  • ✓Supports aggregation with Node.js’s cluster module. [S2]
How this repository's GitHub stars have grown over time. Source: star-history.com.View the star history ↗

Getting Started with Prometheus client_js

Install the package with `npm install @prometheus-io/client`. Expose the result of `await registry.metrics()` from a route in your own HTTP application; the library does not bundle a web framework or endpoint. [S2]

Instrumenting Your Node.js Application with Metrics

The basic loop is: create a metric with a mandatory `name` and `help`, call `.inc()`/`.set()`/`.observe()` on it as your code runs, then answer Prometheus's scrape request with `await registry.metrics()` from whatever HTTP handler you're already running — the library doesn't bundle a web framework, so that route is yours to wire up. For values you can only read at scrape time, like current memory usage rather than something accumulated continuously, pass a `collect()` function instead of updating the metric on a timer; the README is specific that `collect()` — sync or async — fires when the registry gathers values, and a `setInterval` callback is the wrong place for those writes. Labels come from a `labelNames` array on the metric config, then get filled in through `.labels(...).set(...)` or by passing a labels object as the first argument to a call like `.inc()`. Running under Node.js's `cluster` module changes the picture: a worker's local registry only reflects that worker's own numbers, so you instantiate `ClusterRegistry` before branching on `cluster.isPrimary`. Skipping that setup in a worker leaves it unable to answer when the primary asks it to aggregate, so `clusterMetrics()` just stalls until it times out. Custom metrics sum across workers by default; set `aggregator` in the metric config to `'first'`, `'min'`, `'max'`, `'average'`, or `'omit'` when summing isn't the right combination for that particular metric.

Strengths

  • ✓Provides the standard metric types used by Node.js services. [S2]
  • ✓The registry supports Prometheus and OpenMetrics exposition formats. [S2]
  • ✓Supports aggregation with Node.js’s cluster module. [S2]

Considerations and Known Limitations

  • △The library does not bundle a web framework or HTTP endpoint; the application must expose registry output from its own route. [S2]
  • △The declared supported Node.js versions are `^22 || ^24 || >=26`. [S3]
  • △Default file-descriptor and memory metrics are Linux-only. [S2]
  • △Cluster aggregation averages event-loop lag readings across workers, which is less precise than summing other metrics. [S2]
  • △Combining registries with different exposition formats has behavior the README describes as undefined. [S2]

Alternatives for Node.js Metrics Collection

OpenTelemetry JavaScript provides vendor-neutral metrics instrumentation for Node.js and the browser; it is an option when the same instrumentation needs to export to different backends, not a drop-in Prometheus exposition client. [S8]For an existing StatsD deployment, `node-statsd` is a Node.js client for Etsy's StatsD server and uses a push model; its repository is archived, so do not treat it as a maintained new-project replacement. [S9]Elastic APM Node.js Agent auto-instruments supported frameworks and sends performance metrics and errors to APM Server; consider it for teams using Elastic APM, not as a Prometheus client. [S10]

Frequently Asked Questions

What license does Prometheus client_js use?

Prometheus client for Node.js is released under the Apache-2.0 license, as listed on its GitHub repository.

Does Prometheus client_js support Node.js's cluster module?

Prometheus client for Node.js ships a ClusterRegistry that aggregates metrics from every worker into the primary process, since a worker's own registry only reflects its local numbers by default.

Can Prometheus client_js push metrics to a Pushgateway?

Prometheus client for Node.js includes a Pushgateway client with pushAdd, push, and delete methods, plus a requireJobName option for gateways like Gravel Gateway that skip job-name grouping.

What types of metrics does Prometheus client_js support?

Prometheus client for Node.js supports four metric types: Counter, Gauge, Histogram, and Summary.

Does Prometheus client_js support the OpenMetrics format?

Prometheus client for Node.js can emit the OpenMetrics 1.0.0 exposition format per registry, alongside the classic Prometheus 0.0.4 text format it defaults to.

Are there any OS-specific metrics in Prometheus client_js?

Prometheus client for Node.js does have OS-specific metrics: its default file-descriptor and memory readings are only available on Linux, per the README.

The problem it solves

A Node.js process that's slow or failing under load won't tell you why unless something inside it is counting requests, timing them, and tracking memory and event-loop health in a format your monitoring stack can actually scrape. Hand-rolling that layer — picking histogram bucket boundaries, formatting Prometheus's exposition text by hand, keeping Counters from ever going backward — is easy to get subtly wrong. prometheus/client_js exists to standardize that instrumentation layer instead of every team inventing its own metric-naming and formatting conventions.

Best use cases

  • •Instrumenting a Node.js HTTP API with request-count Counters and request-duration Histograms that a Prometheus server scrapes on an interval.
  • •Aggregating metrics across a Node.js `cluster` deployment where each worker would otherwise only expose its own local numbers.
  • •Correlating metrics with distributed traces by attaching exemplars to Counters and Histograms once OpenTelemetry is populating trace and span IDs.
  • •Pushing metrics from short-lived batch or cron jobs to a Pushgateway instead of standing up a long-lived process for Prometheus to scrape.
  • •Moving a registry from the classic Prometheus text format to OpenMetrics without rewriting the metric-type code that produces the values.

Who should try it — and who should skip

Node.js teams that want Counter, Gauge, Histogram, or Summary metrics in a format their Prometheus-compatible scraper can collect, and whose runtime matches the package’s declared Node range (`^22 || ^24 || >=26`). [S2, S3] Version 0.16 changed the published package name from `prom-client` to `@prometheus-io/client` and includes breaking changes; check imports and worker/cluster setup before upgrading an existing deployment. [S5, S6] An open issue and its related pull request propose yielding the event loop during metric export; that work is not part of v0.16.1. [S7]

Related repositories

Source & attribution

Sources checked 2026-11-15: [S2] README pinned to v0.16.1 — https://raw.githubusercontent.com/prometheus/client_js/v0.16.1/README.md; [S3] package.json pinned to v0.16.1 — https://raw.githubusercontent.com/prometheus/client_js/v0.16.1/package.json; [S4] LICENSE pinned to v0.16.1 — https://raw.githubusercontent.com/prometheus/client_js/v0.16.1/LICENSE; [S5] Release v0.16.1 — https://github.com/prometheus/client_js/releases/tag/v0.16.1; [S6] Changelog — https://raw.githubusercontent.com/prometheus/client_js/v0.16.1/CHANGELOG.md; [S7] Issue #877 — https://github.com/prometheus/client_js/issues/877; [S8] OpenTelemetry JavaScript docs — https://opentelemetry.io/docs/languages/js/index.md; [S9] node-statsd README/archive status — https://github.com/sivy/node-statsd; [S10] Elastic APM Node.js Agent docs — https://www.elastic.co/docs/reference/apm/agents/nodejs.md.

GitHub data · last synced Aug 12, 2026Reviewed by Henry
← Back to TopGit

Curious whether client_js is right for you?

Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about client_js.

GitHub