Measured Core

The core measured library that has the Metric interfaces and implementations.

npm

Install

npm install measured-core

What is in this package

Metric Implemenations

The core library has the following metrics classes:

Gauge

Values that can be read instantly via a supplied call back.

SettableGauge

Just like a Gauge but its value is set directly rather than supplied by a callback.

CachedGauge

Like a mix of the regular and settable Gauge it takes a call back that returns a promise that will resolve the cached value and an interval that it should call the callback on to update its cached value.

Counter

Counters are things that increment or decrement.

Timer

Timers are a combination of Meters and Histograms. They measure the rate as well as distribution of scalar events.

Histogram

Keeps a reservoir of statistically relevant values to explore their distribution.

Meter

Things that are measured as events / interval.

Registry

The core library comes with a basic registry class

Collection

that is not aware of dimensions / tags and leaves reporting up to you.

See the measured-reporting module for more advanced and featured registries.

Other

See The measured-core modules for the full list of exports for require('measured-core').

Usage

Step 1: Add measurements to your code. For example, lets track the
requests/sec of a http server:

var http  = require('http');
var stats = require('measured').createCollection();

http.createServer(function(req, res) {
  stats.meter('requestsPerSecond').mark();
  res.end('Thanks');
}).listen(3000);

Step 2: Show the collected measurements (more advanced examples follow later):

setInterval(function() {
  console.log(stats.toJSON());
}, 1000);

This will output something like this every second:

{ requestsPerSecond:
   { mean: 1710.2180279856818,
     count: 10511,
     'currentRate': 1941.4893498239829,
     '1MinuteRate': 168.08263156623656,
     '5MinuteRate': 34.74630977619571,
     '15MinuteRate': 11.646507524106095 } }

Step 3: Aggregate the data into your backend of choice.
Here are a few time series data aggregators.

  • Graphite
    • A free and open source, self hosted and managed solution for time series data.
  • SignalFx
    • An enterprise SASS offering for time series data.
  • Datadog
    • An enterprise SASS offering for time series data.