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
- Install
npm install node-metrics
- Configure
Create a Lynx instance:
var Lynx =dgram = ;var metrics = 'localhost' 8125socket: dgramscope: 'YOUR_NAMESPACE';
Collecting data!
node-metrics provides middleware and library functions for collecting basic health metrics.
Use an individual gauge
;
Or for node connections:
;
Where server is an http server instance (as supplied by app.listen() ).
Use all gauges
To configure all gauges at once, do:
;
Use middleware
Ensure you append your Lynx instance to the req object as req.metrics. Then append middleware like:
app;
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.