express-statsd is a middleware for Connect and Express applications designed to send route-specific metrics (status codes and response times) to a StatsD server. The current and only stable version is 0.3.0, which was last published over 12 years ago, indicating the project is abandoned. While functional, developers should be aware that it is not actively maintained and may not be compatible with modern Node.js or Express versions without potential issues. Newer, actively maintained alternatives like `express-hot-shots` (a direct fork) or comprehensive monitoring solutions like `express-insights` and `express-status-monitor` offer more features, better compatibility, and ongoing support. This middleware distinguishes itself by its simplicity, focusing solely on basic route-level HTTP metrics.
npm install express-statsdVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to integrate `express-statsd` globally and, crucially, how to use `req.statsdKey` to namespace metrics per route for more granular monitoring.
Migrate to a maintained alternative such as `express-hot-shots` or a more comprehensive monitoring library like `express-status-monitor` or `express-insights` for long-term stability and security.
Implement a middleware or set `req.statsdKey` in your route handler before the response is sent. Example: `req.statsdKey = ['http', req.method.toLowerCase(), 'my_route'].join('.');`Ensure your StatsD daemon is actively running and listening on the configured host and port (default: 127.0.0.1:8125). Implement external monitoring for your StatsD daemon and consider adding logging for the `lynx` client's error events if you need more visibility into transmission failures.
This package is CommonJS-only. Ensure you are using `const expressStatsd = require('express-statsd');` in a CommonJS environment or project configured for CommonJS interop.Run `npm install express-statsd` or `yarn add express-statsd` in your project directory to install the package.