npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

prome-string

v0.0.8

Published

prometheus string generator

Downloads

57

Readme

prome-string

prometheus string generator

Install

npm install prome-string

Modules

Metric
Gauge
Counter
Histogram
Summary 

Usage

Counter

  • code
const { Counter } = require('prome-string');

const counter = new Counter({
  name: 'counter_name',
  help: 'counter_help',
  labels: ['labelA', 'labelB'],
});

counter.inc();
counter.dec({ labelA: 'A' });
  
console.log(`${counter}`);
  • result
# HELP counter_name counter_help
# TYPE counter_name gauge
counter_name 1
counter_name{labelA="A"} -1

Gauge

  • code
const { Gauge } = require('prome-string');

const gauge = new Gauge({
  name: 'gauge_name',
  help: 'gauge_help',
  labels: ['labelA', 'labelB'],
});

gauge.set(2);
gauge.set(4, { labelA: 'A' });

console.log(`${gauge}`)
  • result
# HELP gauge_name gauge_help
# TYPE gauge_name gauge
gauge_name 2
gauge_name{labelA="A"} 4

Histogram

  • code
const { Histogram } = require('prome-string');

const histogram = new Histogram({
  name: 'histogram_name',
  help: 'histogram_help',
  labels: ['labelA', 'labelB'],
  buckets: [1, 10, 100, 1000],
});

histogram.set(5);
histogram.set(500);
histogram.set(20, { labelA: 'A' });

console.log(`${histogram}`);
  • result
# HELP histogram_name histogram_help
# TYPE histogram_name histogram
histogram_name_bucket{le="1"} 0
histogram_name_bucket{le="10"} 1
histogram_name_bucket{le="100"} 1
histogram_name_bucket{le="1000"} 2
histogram_name_bucket{le="+Inf"} 2
histogram_name_bucket{labelA="A",le="1"} 0
histogram_name_bucket{labelA="A",le="10"} 0
histogram_name_bucket{labelA="A",le="100"} 1
histogram_name_bucket{labelA="A",le="1000"} 1
histogram_name_bucket{labelA="A",le="+Inf"} 1
histogram_name_sum 505
histogram_name_sum{labelA="A"} 20
histogram_name_count 2
histogram_name_count{labelA="A"} 1

Summary

  • code
const summary = new Summary({
  name: 'summary_name',
  help: 'summary_help',
  labels: ['method'],
  // percentiles: [0.01, 0.1, 0.5, 0.9, 0.99], <default>
  // queueLength: 1000, <default>
  // timeout: Infinity, <default>
});

summary.set(10, { method: 'get' });
summary.set(20, { method: 'get' });

summary.set(100, { method: 'post' });
summary.set(200, { method: 'post' });

console.log(`${summary}`);
  • result
# HELP summary_name summary_help
# TYPE summary_name summary
summary_name{quantile=0.01,method="get"} 10
summary_name{quantile=0.1,method="get"} 10
summary_name{quantile=0.5,method="get"} 15
summary_name{quantile=0.9,method="get"} 20
summary_name{quantile=0.99,method="get"} 20
summary_name{quantile=0.01,method="post"} 100
summary_name{quantile=0.1,method="post"} 100
summary_name{quantile=0.5,method="post"} 150
summary_name{quantile=0.9,method="post"} 200
summary_name{quantile=0.99,method="post"} 200
summary_name_sum{method="get"} 30
summary_name_sum{method="post"} 300
summary_name_count{method="get"} 2
summary_name_count{method="post"} 2