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 🙏

© 2026 – Pkg Stats / Ryan Hefner

blue-matador-metrics-client

v1.0.0

Published

Send StatsD-style custom metrics to your Blue Matador account.

Readme

Blue Matador Metrics Client

Send StatsD-style custom metrics to your Blue Matador dashboard

Installation

  • npm install blue-matador-metric-client

Setup

To start using the Blue Matador metrics client, simply require the package and call the init method.

const blueMatador = require('blue-matador-metrics-client');
const client = blueMatador.init();

Init

init([options])

options is an object with the following keys:

  • host: (optional) specifies the host to send the custom metrics to. If no host is specified, localhost is the default host.
  • port: (optional) specifies the port to send the custom metrics to. If no port is specified, 8767 is the default port.
  • prefix: (optional) a string that will be prepended to the name of every metric you send. Cannot contain ':' or '|'
const blueMatador = require('blue-matador-metrics-client');
const options = {
  host: '127.0.0.1',
  port: 8767,
  prefix: 'app'
}
const client = blueMatador.init(options);

Note: The init function will detect if you have set BLUEMATADOR_AGENT_HOST and BLUEMATADOR_AGENT_PORT in the config file for your agent. Manually setting the host or port through the options object will override environmental variables.

Once you have an instance of the Blue Matador metrics client in your code you can start sending custom metrics. A Blue Matador agent must be configured to receive metrics at the destination host and port.

Gauge

gauge(name, value, [options])

  • name: (required) The metric name e.g. 'myapp.request.size'. Cannot contain ':' or '|'
  • value: (required) The latest value to set for the metric

options is an object with the following keys:

  • sampleRate: (optional) sends only a sample of data e.g. 0.5 indicates 50% of data being sent. Default value is 1
  • labels: (optional) adds metadata to a metric. Can be specified as object or array of strings with key-value pairs formatted with a colon separator e.g. ['account:12345'] or {account: 12345}. Cannot contain '#' or '|'

The gauge method is asynchronous and returns a Promise that can be chained on with .then() and .catch()

If the metric is successfully sent to the Blue Matador Agent the .then() response will return the metric that was sent.

const blueMatador = require('blue-matador-metrics-client');
const client = blueMatador.init();

const options = {
  sampleRate: 0.75,
  labels: { environment: 'Prod', account_id: 1232151 }
}

client.gauge('request.size', 32.25, options);

The following are all valid ways to send a gauge metric:

# gauge 100
client.gauge("request.size", 100);

# gauge 100 but sample 50%
client.gauge("request.size", 100, { sampleRate: 0.5 });

# gauge 100 with labels
client.gauge("request.size", 100, { labels: ["environment:Prod", "api"] });

# gauge 100, sample 50%, and send labels
client.gauge("request.size", 100, { sampleRate: 0.5, labels: ["environment:Prod", "api"] });

Count

count(name, options)

  • name: (required) The metric name e.g. 'myapp.request.size'. Cannot contain ':' or '|'

options is an object with the following keys:

  • value: (optional) the amount to increment the metric by, the default is 1.
  • sampleRate: (optional) sends only a sample of data e.g. 0.5 indicates 50% of data being sent. Default value is 1
  • labels: (optional) adds metadata to a metric. Can be specified as object or array of strings with key-value pairs formatted with a colon separator e.g. ['account:12345'] or {account: 12345}. Cannot contain '#' or '|'

The count method is asynchronous and returns a Promise that can be chained on with .then() and .catch()

If the metric is successfully sent to the Blue Matador Agent the .then() response will return the metric that was sent.

const blueMatador = require('blue-matador-metrics-client');
const client = blueMatador.init();

const options = {
  value: 1,
  sampleRate: 1,
  labels: { environment: 'Prod', account_id: 1232151 }
}

client.count('homepage.clicks', options)

The following are all valid ways to send a count metric:

# count 1
client.count("homepage.clicks");

# count 2
client.count("hompage.clicks", { value: 2 });

# count 1 but sample 50%
client.count("homepage.clicks", { value: 1, sampleRate: 0.5 });

# count 2 and send labels
client.count("homepage.clicks", { value: 2, labels: ["environment:Prod", "homepage"] });

# count 2, sample 50%, and send labels
client.count("homepage.clicks",{ value: 2, sampleRate: 0.5, labels: ["environment:Prod", "homepage"] });

Close

The close method should be called when shutting down your app.

client.close();

License

More details in LICENSE.

Copyright (c) 2020 Blue Matador, Inc.