Skip to content

Express middleware that exposes statistical information, status and other useful information

License

Notifications You must be signed in to change notification settings

chieffancypants/express-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express-stats

Express middleware that exposes statistical information, status and other useful information to an express-backed application.

This software is currently early alpha -- not all functionality is present and is subject to change.

Example

var
  express = require('express'),
  stats   = require('express-stats'),
  app     = module.exports = express();

app.configure(function() {
  app.use(express.responseTime());
  app.use(stats());
  app.use(app.router);
});

// Start server
app.listen(3000, function() {
  console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});

This will output the following json:

{
  "status": "ok",
  "pid": 6674,
  "uptime": "2m 3s",
  "response_time_avg": "62ms",
  "env": "development",
  "memory": {
    "rss": 37130240,
    "heapTotal": 32159232,
    "heapUsed": 18477064
  },
  "node": {
    "http_parser": "1.0",
    "node": "0.10.5",
    "v8": "3.14.5.8",
    "ares": "1.9.0-DEV",
    "uv": "0.10.5",
    "zlib": "1.2.3",
    "modules": "11",
    "openssl": "1.0.1e"
  }
}

Configuration

You specify options during the express.js configuration:

app.use(stats({ url: '/health-status' }));

Options:

  • url the path the stats collection should bind to for reporting. Defaults to /health
  • cacheSize The in-memory cache size for the stats. Records the last N response times. Defaults to 100
  • statusCheck Pass a function that should be used to determine whether the app is up or not. Defaults to simply returning ok

License

MIT License

See the LICENSE file for more info.

About

Express middleware that exposes statistical information, status and other useful information

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published