express-lynx

1.0.1 • Public • Published

express-lynx

Express Middleware for sending data to StatsD and then grapphite.

Please refer to the Lynx documentation for more in depth details for configuring the Lynx StatsD Client.

Once your client is configured, it's pretty straight forward to configure express-lynx.

Installation:

npm install express-lynx

Configuration:

 
// Import lynx and express-lynx
var lynx = require('lynx');
var expressLynx = require('express-lynx');
 
// Setup your Lynx StatsD client as normal, optionally passing a prefix (like 'express'), or [hostname] (http://nodejs.org/api/os.html#os_os_hostname)
var metrics = new lynx('localhost', 8125, {prefix: 'express'});
 
// Create the Express middleware passing in the Lynx StatsD Client you created
var statsdMiddleware = expressLynx(metrics);
 
// Tell Express to use your statsD middleware
server.use(statsdMiddleware());

By default express-lynx will track the counts for each response code and a response time for the overall system. What's more useful is to have timing for each route in your Express app. express-lynx can be configured to give you per-route timing by adding an option timeByUrl to the middleware constructor.

server.use(statsdMiddleware({timeByUrl: true})}

Additional Reading

Package Sidebar

Install

npm i express-lynx

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • clodio