node-process-metrics-prometheus
v0.1.0
Published
retrieve Node.js process metrics in exposition format
Downloads
33
Readme
node-process-metrics-prometheus
Get process, system, memory, CPU, and event loop metrics from a Node.js process in Prometheus text-based exposition format. Can be used synchronously, or as an event emitter.
Basic Usage
'use strict';
const NodeProcessMetrics = require('node-process-metrics');
const NodeProcessMetricsPrometheus = require('node-process-metrics-prometheus');
// Use synchronously
const pm = new NodeProcessMetricsPrometheus();
console.log(pm.metrics());
// Use as an event emitter
const pm = new NodeProcessMetricsPrometheus({
metrics: new NodeProcessMetrics({ period: 1000 })
});
pm.on('metrics', (metrics) => {
console.log(metrics);
});
API
node-process-metrics
exports a single constructor with the following API.
NodeProcessEmitter([options])
- Arguments
options
(object) - An optional configuration supporting the following options:metrics
(number) - An instance ofNodeProcessMetrics
. Optional. If not provided, a new instance is constructed.registries
(array) - An array ofCollectorRegistry
instances. Optional. Defaults to[PromDress.defaultRegistry]
.
'metrics'
Event
The 'metrics'
event has one accompanying argument - a Prometheus exposition string.