Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🚀 Realtime Monitoring solution for Node.js/Express.js apps, inspired by status.github.com, sponsored byhttps://dynobase.dev

License

NotificationsYou must be signed in to change notification settings

RafalWilinski/express-status-monitor

Repository files navigation

express-status-monitor on npmnpmCircleCIOpen Source Helpers

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

Monitoring Page

Demo

Demo available here

Support for other Node.js frameworks

Installation & setup

  1. Runnpm install express-status-monitor --save
  2. Before any other middleware or router add following line:app.use(require('express-status-monitor')());
  3. Run server and go to/status

Note: This plugin works on Node versions > 4.x

Run examples

  1. Go tocd examples/
  2. Runnpm i
  3. Run servernpm start
  4. Go tohttp://0.0.0.0:3000

Options

Monitor can be configured by passing options object intoexpressMonitor constructor.

Default config:

title:'Express Status',// Default titletheme:'default.css',// Default stylespath:'/status',socketPath:'/socket.io',// In case you use a custom pathwebsocket:existingSocketIoInstance,spans:[{interval:1,// Every secondretention:60// Keep 60 datapoints in memory},{interval:5,// Every 5 secondsretention:60},{interval:15,// Every 15 secondsretention:60}],chartVisibility:{cpu:true,mem:true,load:true,eventLoop:true,heap:true,responseTime:true,rps:true,statusCodes:true},healthChecks:[],ignoreStartsWith:'/admin'

Health Checks

You can add a series of health checks to the configuration that will appear below the other stats. The health check will be considered successful if the endpoint returns a 200 status code.

// confighealthChecks:[{protocol:'http',host:'localhost',path:'/admin/health/ex1',port:'3000'},{protocol:'http',host:'localhost',path:'/admin/health/ex2',port:'3000'}]

Health Checks

Securing endpoint

The HTML page handler is exposed as apageRoute property on the mainmiddleware function. So the middleware is mounted to intercept all requestswhile the HTML page handler will be authenticated.

Example usinghttps://www.npmjs.com/package/connect-ensure-login

constensureLoggedIn=require('connect-ensure-login').ensureLoggedIn()conststatusMonitor=require('express-status-monitor')();app.use(statusMonitor);app.get('/status',ensureLoggedIn,statusMonitor.pageRoute)

Credits to@mattiaerre

Example usinghttp-auth

constauth=require('http-auth');constbasic=auth.basic({realm:'Monitor Area'},function(user,pass,callback){callback(user==='username'&&pass==='password');});// Set '' to config path to avoid middleware serving the html page (path must be a string not equal to the wanted route)conststatusMonitor=require('express-status-monitor')({path:''});app.use(statusMonitor.middleware);// use the "middleware only" property to manage websocketsapp.get('/status',basic.check(statusMonitor.pageRoute));// use the pageRoute property to serve the dashboard html page

Using module with socket.io in project

If you're using socket.io in your project, this module could break your project because this module by default will spawn its own socket.io instance. To mitigate that, fill websocket parameter with your main socket.io instance as well as port parameter.

Tests and coverage

In order to run test and coverage use the following npm commands:

npm testnpm run coverage

License

MIT License ©Dynobase

About

🚀 Realtime Monitoring solution for Node.js/Express.js apps, inspired by status.github.com, sponsored byhttps://dynobase.dev

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors34


[8]ページ先頭

©2009-2025 Movatter.jp