prometheus-plugin-meta
v2.0.0
Published
Node.js prometheus meta plugin that provides API for working with all prometheus-plugin-* at once
Downloads
5
Maintainers
Readme
prometheus-plugin-meta
Node.js prometheus meta (all-in-one) plugin that provides API for working with all plugins at once.
Installation
npm i -S prometheus-plugin-meta
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-4.0.0
because this module uses ES6 syntax- Valid
package.json
file in$PWD
Plugin list
- prometheus-plugin-app-info
- prometheus-plugin-cpu-stats
- prometheus-plugin-eventloop-stats
- prometheus-plugin-heap-stats
- prometheus-plugin-memory-stats
- prometheus-plugin-gc-stats
- prometheus-plugin-tcp-stats
Usage
Simple
const client = require('prom-client');
const appInfoPlugin = require('prometheus-plugin-meta');
// start metrics collection
appInfoPlugin.init().start();
// log metrics to console
console.log(client.register.metrics());
// stop metrics collection
appInfoPlugin.stop();
// stop and clear metrics register
appInfoPlugin.reset();
Override metric defaults
const client = require('prom-client');
const appInfoPlugin = require('prometheus-plugin-meta');
const override = {
'prometheus-plugin-pluginname': {
'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
appInfoPlugin.init(override).start(); // pass override object to init function
// log metrics to console
console.log(client.register.metrics());
// stop metrics collection
appInfoPlugin.stop();
// stop and clear metrics register
appInfoPlugin.reset();