Skip to content

〰️ Realtime Monitoring solution for Trek.js, inspired by status.github.com

License

Notifications You must be signed in to change notification settings

trekjs/status-monitor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

trek-status-monitor

Simple, self-hosted module based on Socket.io and Chart.js to report realtime server metrics for Trek-based node servers.

Forked from express-status-monitor.

Monitoring Page

Installation

$ npm install trek-status-monitor --save

Example

const Engine = require('trek-engine')

// setups & configs status monitor.
const statusMonitor = require('trek-status-monitor')({
  title: 'Trek Status',
  path: '/status'
})

const app = new Engine()

// registers status monitor's middleware
app.use(statusMonitor.middleware)

app.use(({ req, res, rawRes }) => {
  // registers status monitor's page route, defaults to `/status`
  if (req.path === statusMonitor.path) {
    return statusMonitor.page({ rawRes })
  }
  res.end('Hello world')
})

app.run(3000, () => {
  console.log('listening on http://0.0.0.0:3000')
})
$ npm i
$ node examples/index.js
$ open http://0.0.0.0:3000/status

APIs

  • config: Object

    Monitor can be configured by passing options object into statusMonitor constructor.

    Default config:

    {
      title: 'Trek Status',     // Default title
      path: '/status',
      spans: [{
        interval: 1,            // Every second
        retention: 60           // Keep 60 datapoints in memory
      }, {
        interval: 5,            // Every 5 seconds
        retention: 60
      }, {
        interval: 15,           // Every 15 seconds
        retention: 60
      }]
    }
  • path: String

    Alias to config.path, defaults to /status.

  • middleware: Function

    The Trek's middleware.

    app.use(statusMonitor.middleware)

  • page: Function

    The Trek's middleware, but using for the special route.

    router.get(statusMonitor.path, statusMonitor.page)

Badges

Build Status codecov


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

About

〰️ Realtime Monitoring solution for Trek.js, inspired by status.github.com

Resources

License

Stars

Watchers

Forks

Packages

No packages published