JSPM

prometheus-plugin-cpu-stats

2.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q13664F
  • License UNLICENSE

Node.js prometheus client plugin for exporting cpu time statistics.

Package Exports

  • prometheus-plugin-cpu-stats

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (prometheus-plugin-cpu-stats) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

prometheus-plugin-cpu-stats

Node.js prometheus client plugin for collecting cpu usage statistics.

build status coverage report

Installation

npm i -S prometheus-plugin-cpu-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-4.0.0 because this module uses ES6 syntax

Metric list

  • Total CPU time spent in seconds
    • type: 'Counter'
    • name: 'nodejs_cpu_seconds_total'
    • labels: ['type'] - 'user' | 'system'

Usage

Simple

const client = require('prom-client');
const templatePlugin = require('prometheus-plugin-cpu-stats');

// start metrics collection
templatePlugin.init().start();

// log metrics to console
console.log(client.register.metrics());

// stop metrics collection
templatePlugin.stop();

// stop and clear metrics register
templatePlugin.reset();

Override metric defaults

const client = require('prom-client');
const metric_name = require('prometheus-plugin-cpu-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
metric_name.init(override).start(); // pass override object to init function

// log metrics to console
console.log(client.register.metrics());

// stop metrics collection
metric_name.stop();

// stop and clear metrics register
metric_name.reset();