Git Product home page Git Product logo

express-stats's Introduction

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.

express-stats's People

Contributors

chieffancypants avatar

Watchers

James Cloos avatar Karthikeyan avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.