Socket
Socket
Sign inDemoInstall

prom-client

Package Overview
Dependencies
Maintainers
0
Versions
84
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prom-client

Client for prometheus


Version published
Weekly downloads
790K
decreased by-61.73%
Maintainers
0
Weekly downloads
 
Created

What is prom-client?

The prom-client npm package is a client for the Prometheus monitoring tool, which allows you to collect and expose metrics from your Node.js applications. It supports various metric types, custom labels, and can be integrated with the default Node.js metrics and other systems.

What are prom-client's main functionalities?

Counter

Counters are a metric that only goes up (e.g., page views, total number of requests).

const { Counter } = require('prom-client');
const httpRequestsTotal = new Counter({
  name: 'http_requests_total',
  help: 'Total number of HTTP requests'
});

httpRequestsTotal.inc(); // Increment by 1
httpRequestsTotal.inc(5); // Increment by a given value

Gauge

Gauges are a metric that can go up or down (e.g., memory usage, number of active users).

const { Gauge } = require('prom-client');
const memoryUsageGauge = new Gauge({
  name: 'memory_usage_bytes',
  help: 'Memory usage in bytes'
});

memoryUsageGauge.set(process.memoryUsage().heapUsed); // Set to current heap used

Histogram

Histograms track the size and number of events in buckets (e.g., request durations or response sizes).

const { Histogram } = require('prom-client');
const httpRequestDuration = new Histogram({
  name: 'http_request_duration_seconds',
  help: 'Duration of HTTP requests in seconds',
  buckets: [0.1, 0.2, 0.5, 1, 5]
});

httpRequestDuration.observe(0.4); // Observe a value in seconds

Summary

Summaries calculate percentiles of observed values (e.g., long-tail request durations).

const { Summary } = require('prom-client');
const httpRequestDurationSummary = new Summary({
  name: 'http_request_duration_summary',
  help: 'Summary of HTTP request durations',
  percentiles: [0.5, 0.9, 0.99]
});

httpRequestDurationSummary.observe(0.3); // Observe a value in seconds

Default Metrics

Collect default metrics from Node.js runtime and system, such as CPU usage, event loop lag, etc.

const { collectDefaultMetrics } = require('prom-client');
collectDefaultMetrics();

Other packages similar to prom-client

Keywords

FAQs

Package last updated on 27 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc