0.6.0 • Published 5 years ago

prom2json-se v0.6.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
5 years ago

Prom2Json SE

npm

Description

This small module is helping with conversion between Prometheus string output and JSON. JSON format is not standard output for Prometheus, but some processors prefer to use that one over any other.

Some snippets are inspired by https://github.com/anasceym/prom2json-stream

Installation

// If you use npm
npm i prom2json-se -S

// If you use yarn
yarn add prom2json-se

How to use

// Load module
const prom2Json = require('./');

// Use module
const promString = `
...
`;
const promJson = prom2Json.convert(promString);

Simple example with Prometheus client:

const express = require('express');
const app = express();

...

const Prometheus = require('prom-client');
const prom2Json = require('prom2json-se');

// Default Metrics (every 10s)
Prometheus.collectDefaultMetrics();

// Add metrics endpoint
app.use('/metrics-json', (req, res) => {
  const json = prom2Json.convert(Prometheus.register.metrics());
  res.send(json);
});

...

app.listen(process.env.PORT || 3000);

License

This module has MIT license.

0.6.0

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago