1.0.11 • Published 9 years ago

node-metrics v1.0.11

Weekly downloads
239
License
MIT
Repository
github
Last release
9 years ago

node-metrics

Easily forward a node app's basic health metrics to a local statsd instance.

Development

Install dependencies:

  npm install

Run tests:

  npm test

Usage

  1. Install

    npm install node-metrics
  2. Configure

    Create a Lynx instance:

    var Lynx = require('lynx'),
        dgram = require('dgram');
    
    var metrics = new Lynx('localhost', 8125, {
      socket: dgram.createSocket('udp4'),
      scope: 'YOUR_NAMESPACE'
    });

Collecting data!

node-metrics provides middleware and library functions for collecting basic health metrics.

Use an individual gauge

  require('node-metrics').nodeMemoryGauge(metrics);

Or for node connections:

  require('node-metrics').nodeConnectionsGauge(metrics, server);

Where server is an http server instance (as supplied by app.listen() ).

Use all gauges

To configure all gauges at once, do:

  require('node-metrics').allGauges(metrics, server);

Use middleware

Ensure you append your Lynx instance to the req object as req.metrics. Then append middleware like:

  app.use(require('node-metrics').requestStatsMiddleware);

Note that for requestStatsByRouteMiddleware, stats will only be logged for a route if req.route is present. Further, your route names will be cleaned of any characters that might interfere with stasd's protocol.

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago