https://github.com/statful/statful-middleware-express
Middleware for Express servers to gather and send metrics to Statful.
https://github.com/statful/statful-middleware-express
express expressjs metrics middleware nodejs performance restify statful
Last synced: about 1 year ago
JSON representation
Middleware for Express servers to gather and send metrics to Statful.
- Host: GitHub
- URL: https://github.com/statful/statful-middleware-express
- Owner: statful
- License: mit
- Created: 2017-07-08T11:16:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T02:44:25.000Z (over 3 years ago)
- Last Synced: 2025-04-29T14:07:53.663Z (about 1 year ago)
- Topics: express, expressjs, metrics, middleware, nodejs, performance, restify, statful
- Language: JavaScript
- Homepage: https://www.statful.com/
- Size: 1.17 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# statful-middleware-express
A common pattern in expressjs/restify applications it to gather response times from all received requests, this middleware takes care of collecting common useful metrics automatically.
[](https://badge.fury.io/js/statful-middleware-express) [](https://travis-ci.org/statful/statful-middleware-express)
## Installing
```shell
npm install --save statful-middleware-express statful-client
```
```shell
yarn add statful-middleware-express statful-client
```
## Getting started
```js
const express = require("express");
const Statful = require("statful-client");
const statfulMiddleware = require("statful-middleware-express");
const app = express();
const statful = new Statful({
/* statful configuration */
});
app.use(statfulMiddleware(statful));
app.listen(3000);
```
## Configuration
Most of the configuration is done directly in the statful instance. You can read more about the available options directly from the [Statful repository](https://github.com/statful/statful-client-nodejs#global-configuration).
## Default Metrics
By default, the follow metrics are collected, with the corresponding tags:
- `response_time`
- `hostname`
- `method`: GET, POST, PUT ...
- `statusCode`: 200, 400, 404 ...
- `statusCodeCategory`
- informational
- success
- redirection
- client_error
- server_error
- `route`: Either the route handler's name, the route path or `unknown_route`. e.g.: `/users/:id?`
## Authors
[Mindera - Software Craft](https://github.com/Mindera)
## License
statful-middleware-express is available under the MIT license. See the [LICENSE](https://raw.githubusercontent.com/statful/statful-middleware-express/master/LICENSE.md) file for more information.