prometheus-plugin-heap-stats
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

prometheus-plugin-heap-stats

Node.js prometheus client plugin for collecting detailed heap spaces statistics.

build status coverage report

Installation

npm i -S prometheus-plugin-heap-stats

Requirements

  • >=prom-client-4.0.0 npm module (installed as peer dependency). If your project depends on previous version of client this plugin might not work.
  • >=node-6.0.0 because this module heap space stat function introduced in node 6.0.0

Metric list

  • Process heap space sizes in bytes
    • type: 'Gauge'
    • name: 'nodejs_heap_space_size_bytes'
    • labels: ['type', 'space']
      • type: 'used' | 'total' | 'available'
      • space: 'new' | 'old' | 'map' | 'code' | 'large_object'

Usage

Simple

const client = require('prom-client');
const heapPlugin = require('prometheus-plugin-heap-stats');
 
// start metrics collection
heapPlugin.init().start();
 
// log metrics to console
console.log(client.register.metrics());
 
// stop metrics collection
heapPlugin.stop();
 
// stop and clear metrics register
heapPlugin.reset();

Override metric defaults

const client = require('prom-client');
const heapPlugin = require('prometheus-plugin-heap-stats');
const override = {
  'metric_name': { // provide default metric name to override it's params
    type: 'Counter', // could be changed, but it's not recommended
    name: 'my_metric_name', // name could be changed
    description: 'My custom description', // description could be changed
    labelValues: { // additional labels
      customLabel: 'hello', // custom labels could be added
      customFnLabel: () => { return new Date() } // if it's a function, it will be called to get label value in runtime
    }
  }
};
// start metrics collection
heapPlugin.init(override).start(); // pass override object to init function
 
// log metrics to console
console.log(client.register.metrics());
 
// stop metrics collection
heapPlugin.stop();
 
// stop and clear metrics register
heapPlugin.reset();

Package Sidebar

Install

npm i prometheus-plugin-heap-stats

Weekly Downloads

1

Version

2.0.0

License

UNLICENSE

Last publish

Collaborators

  • m03geek