DEV.co
Open-Source Observability · prometheus

client_js

Prometheus client_js is the official Node.js client library for Prometheus monitoring. It provides instrumentation for counters, gauges, histograms, and summaries, with built-in default metrics for runtime and process monitoring.

Source: GitHub — github.com/prometheus/client_js
3.5k
GitHub stars
402
Forks
JavaScript
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryprometheus/client_js
Ownerprometheus
Primary languageJavaScript
LicenseApache-2.0 — OSI-approved
Stars3.5k
Forks402
Open issues107
Latest releasev15.1.3 (2024-06-27)
Last updated2026-07-08
Sourcehttps://github.com/prometheus/client_js

What client_js is

Apache-2.0 licensed JavaScript library enabling Node.js applications to expose Prometheus metrics via a scrape endpoint. Supports metric types (counter, gauge, histogram, summary), custom registries, multi-process aggregation via cluster module, and on-demand collection.

Quickstart

Get the client_js source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/prometheus/client_js.gitcd client_js# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Production Node.js monitoring infrastructure

Instrument Node.js services to expose metrics for Prometheus scraping; integrate with existing Prometheus deployments for centralized observability.

Microservices with cluster mode

Use AggregatorRegistry to collect metrics from multiple worker processes and expose aggregated metrics in the master process.

Custom application metrics alongside runtime visibility

Combine built-in process/GC/event-loop metrics with custom business logic counters and latency histograms.

Implementation considerations

  • Expose metrics endpoint via custom HTTP handler (library does not bundle web framework); call `registry.metrics()` and respond with text/plain content-type.
  • Configure custom metric buckets and percentiles upfront; changing histogram buckets after metrics are scraped breaks cardinality consistency.
  • For cluster deployments, use AggregatorRegistry explicitly or default registry aggregation will miss multi-worker insights.
  • Event loop lag percentiles are averaged across workers, not properly aggregated; document this limitation in SLOs.
  • Test `collect()` function performance; synchronous or promise-based collection is invoked on every Prometheus scrape (typically 15–60s intervals).

When to avoid it — and what to weigh

  • Non-Prometheus monitoring stack — This client is Prometheus-specific. If you use Datadog, New Relic, or other backends, use their native client instead.
  • Minimal overhead is critical — Default metrics collection (event loop sampling at 10ms precision, GC tracking) introduces measurable CPU overhead in latency-sensitive applications.
  • Synchronous request handling only — The library requires async context (promise-aware collect functions). If you cannot use promises/async-await, integration becomes cumbersome.
  • File descriptor / memory metrics on non-Linux — Some default metrics (FD count, memory details) are Linux-only; Windows/macOS users see partial metric coverage.

License & commercial use

Apache License 2.0 (Apache-2.0)—a permissive OSI-approved license.

Commercial use is permitted under Apache-2.0. Requires inclusion of license text and notice of modifications. Not a warranty or liability guarantee; review Apache-2.0 terms for your use case.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

No sensitive data exposure documented. Metrics endpoint is unencrypted by default (relies on application-level TLS/auth). Review custom metric names to avoid leaking PII (e.g., user IDs, API keys). No known CVEs recorded in data; standard security review recommended for production deployments.

Alternatives to consider

prom-client (npm)

Appears to be the same or equivalent project (Prometheus official client). Verify package name in your dependency manager.

StatsD + telegraf/influx

If you prefer a push-based, lower-cardinality metrics pipeline with less overhead; requires different instrumentation.

OpenTelemetry JS (with Prometheus exporter)

For multi-vendor observability (traces, logs, metrics); heavier instrumentation but vendor-agnostic.

Software development agency

Build on client_js with DEV.co software developers

Add Prometheus metrics in minutes. Install @prometheus/client, register metrics, and expose your /metrics endpoint.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

client_js FAQ

Does this library support TypeScript?
Not clearly stated in the data. Check the repository for .d.ts files or review npm package for type definitions.
Can I use multiple registries in one application?
Yes. Create separate `Registry` instances and pass them to metric constructors. For cluster mode, use `AggregatorRegistry.setRegistries()` on workers.
What is the performance impact of default metrics collection?
Unknown from data. Event loop sampling at 10ms default precision incurs CPU cost. Benchmark in your environment; tune `eventLoopMonitoringPrecision` if needed.
How do I filter or deny certain metric types?
Not supported. You must use a custom registry and selectively register metrics you want to expose.

Custom software development services

DEV.co helps companies turn open-source tools like client_js into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source observability stack.

Ready to instrument your Node.js app?

Add Prometheus metrics in minutes. Install @prometheus/client, register metrics, and expose your /metrics endpoint.