Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsFor a continuously running Node.js SaaS API, expose a /metrics endpoint and let Prometheus scrape it. Pull scraping gives you the normal per-target up health signal and lets a target’s metrics follow the target’s lifecycle. Use Pushgateway only for the narrower case of a short-lived service-level batch job whose result must remain available after the process exits.
Pull or push: which fits your workload?
The key distinction is not whether the Node.js client supports pushing—it does—but whether Prometheus can scrape the workload directly and whether the metrics describe a running instance or a completed job.
As an Amazon Associate I earn from qualifying purchases.
| Question | Pull scraping | Pushgateway |
|---|---|---|
| What workload fits? | A long-running API, worker, or service process. | A short-lived job that may finish before Prometheus can scrape it. |
| What should the metric describe? | Per-process or per-instance state and behavior. | A service-level job outcome that is independent of one machine or process instance. |
| How is health observed? | Prometheus scrape health and the generated up series help reveal a failed or unreachable target. |
Pushed metrics do not provide the ordinary per-target scrape health signal. |
| What happens when the process disappears? | The target’s metrics follow its lifecycle. | Pushed series remain until explicitly deleted, so cleanup must be managed. |
| What infrastructure is needed? | Prometheus must be able to reach the target endpoint. | The job cannot be scraped directly and a reachable gateway must be available. |
| What extra failure risk is introduced? | No additional gateway is needed for the push path. | A shared gateway may become a bottleneck or single point of failure. |
How to expose custom metrics from a Node.js service
The Prometheus client-library directory lists Node.js as an unofficial third-party client, not an official Prometheus-maintained language client. Its linked Node.js client repository describes the package as @prometheus-io/client, previously published as prom-client. Package names and APIs can change, so check the repository’s current installation and migration guidance when adding or upgrading the dependency.
- Install and configure the client. Follow the current package instructions in the client repository.
- Define the metrics you need. The client documents custom counters, gauges, histograms, and summaries, along with optional default Node.js runtime metrics.
- Serve the registry from an endpoint. In the repository’s example pattern, the handler returns
await registry.metrics()in response to a scrape request. - Configure Prometheus to scrape that endpoint. The service should be reachable from the Prometheus server over the network.
The client’s optional runtime metrics include observations such as event-loop lag, active handles, garbage-collection data, and Node.js version. Its README notes that some file-descriptor and memory metrics are Linux-only. For values that should be sampled at scrape time, the client also documents a collect() callback.
#1 Best Overall
Which metrics should a small SaaS API start with?
Request volume, errors, and latency
For an online-serving API, start with request or query count, errors, and latency. In-progress requests may also be useful. Prometheus’s instrumentation guidance recommends aligning count, error, and latency measurements consistently; counting completed queries helps those observations line up.
Choose a metric type for the value
- Counter: cumulative events that only increase during a process lifetime, such as total requests. A process restart can reset the value.
- Gauge: a value that can rise or fall, such as the number of requests currently in progress or another point-in-time measurement.
- Histogram or summary: distributions such as request duration. They are not interchangeable; choose based on the aggregation and percentile behavior your deployment needs.
Use rate() with counters when you need their per-second increase. Do not apply rate() to gauges.
Keep label values bounded
Every distinct combination of label values creates a time series, so labels can multiply the series a metric produces. Prometheus advises: “As a general guideline, try to keep the cardinality of your metrics below 10, and for metrics that exceed that, aim to limit them to a handful across your whole system.” It also recommends investigating alternatives for metrics with cardinality above 100 or that could grow that high. These are guidance thresholds, not performance guarantees.
Avoid unbounded labels such as user IDs and request IDs. Bounded values such as method or status class are more appropriate when they answer a real operational question. If a metric should have a known default before its first event, export that default where appropriate; labeled series generally cannot be exported until their label values are known. The client README also documents explicitly zeroing expected label combinations for histograms.
When Pushgateway is appropriate—and what to manage
Consider Pushgateway when a short-lived service-level batch job exits before Prometheus can scrape it, but its outcome still needs to be available. Useful job metrics can include last success, stage and overall runtime, last completion, and job-level totals. Keep the metric about the job outcome rather than tying it to a transient machine or process instance.
Pushgateway changes the lifecycle responsibilities: pushed series persist until deleted, so the job or an operational cleanup process must remove obsolete data. The shared gateway also becomes another dependency. The Node.js client documents Pushgateway methods such as push, add, and delete; that capability does not make pushing suitable for a long-running API.
Rank #4
If a batch job runs more often than every 15 minutes, Prometheus’s instrumentation guidance gives that frequency as an example of when to consider converting it into a daemon. For machine-related batch-job metrics, the guidance points to the Node Exporter textfile collector rather than Pushgateway.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What if Prometheus cannot reach the service?
Prometheus advises keeping its server on the same network as monitored instances when possible. If firewalls or NAT prevent direct scraping, its guidance suggests moving Prometheus behind the network barrier or considering PushProx. That connectivity problem alone does not make Pushgateway the default for an always-running service; choose a collection approach that preserves clear target health and lifecycle handling where possible.
Best Value
Prometheus’s FAQ summarizes its general preference carefully: “Overall, we believe that pulling is slightly better than pushing, but it should not be considered a major point when considering a monitoring system.” For a small SaaS service, make the decision around workload lifetime, metric meaning, reachability, and cleanup—not merely the existence of a push method in a client library.
Where dashboards fit
Collection and visualization are separate choices. Prometheus’s FAQ recommends Grafana for production dashboards; it can be an optional visualization layer after Prometheus is collecting the metrics.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




