New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

prom2json-se

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prom2json-se

[![npm][npm-badge]][npm-url]

latest
Source
npmnpm
Version
0.6.0
Version published
Maintainers
1
Created
Source

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.

Keywords

prometheus

FAQs

Package last updated on 12 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts