express-status-monitor-plus
v3.1.1
Published
A modern, real-time monitoring dashboard for Express.js featuring persistent metrics, upstream health checks, response percentiles, and zero-config setup.
Maintainers
Readme
Express Status Monitor Plus is a lightweight, production-ready Application Performance Monitoring (APM) tool. It provides a beautiful, modern dashboard to track your server's health in real-time.
As an independent, heavily upgraded fork of the original express-status-monitor, this Plus version introduces critical enterprise features like persistent metrics across restarts, P50/P95/P99 percentiles, dark mode, and upstream health checks—all without the steep cost of commercial APMs like Datadog or New Relic.
✨ Why choose "Plus"? (Key Features)
- 💾 Persistent Storage: Metrics survive process restarts and deployments via a highly optimized, file-based ring buffer.
- 📊 Advanced Percentiles: Built-in reservoir sampling for P50, P95, and P99 response time tracking to catch edge-case latency.
- 🏥 Service Health Checks: Monitor the uptime of your upstream services and third-party APIs directly from the dashboard.
- 🎨 Modernized UI: Glassmorphism headers, dark/light/system themes, interactive charts with smooth animations.
- ⚡ Ultra-Lightweight: Just one single middleware and a ~200 KB bundled frontend. Zero massive dependencies.
- 📈 Comprehensive Metrics: Tracks CPU, memory, heap, load average, event loop latency, response times, requests/sec, and HTTP status codes.
📦 Installation
npm install express-status-monitor-plus
Requires Node.js ≥ 18
🚀 Quick Start
Add the monitor as the very first middleware in your Express application, before any other routes or middleware.
const express = require('express');
const statusMonitor = require('express-status-monitor-plus');
const app = express();
// Initialize the dashboard and data collection
app.use(statusMonitor());
app.get('/', (req, res) => res.send('Hello World'));
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
console.log('Dashboard available at http://localhost:3000/status');
});
Navigate to http://localhost:3000/status to view your live metrics!
⚙️ Advanced Configuration
Pass a configuration object to tailor the dashboard exactly to your infrastructure needs.
app.use(statusMonitor({
title: 'Express Status Monitor Plus', // Dashboard page title
path: '/status', // Dashboard URL path
socketPath: '/socket.io', // Socket.io endpoint path
darkMode: 'auto', // 'auto' | 'dark' | 'light'
// Storage & Persistence
dataDir: '/var/data/my-app/metrics', // Custom metrics directory
flushInterval: 30, // Seconds between disk writes
// Data retention rules (interval in seconds, retention in data points)
spans: { interval: 5, retention: 60 }, // 1 point/5sec, keep for 5 min
// Exclude specific routes from tracking
ignoreStartsWith: '/admin',
// Toggle specific charts
chartVisibility: {
cpu: true,
mem: true,
load: true,
heap: true,
eventLoop: true,
responseTime: true,
rps: true,
statusCodes: true,
},
}));
🏥 Upstream Health Checks
Keep an eye on the databases, microservices, or external APIs your Express app relies on. Endpoints returning a 200 OK are marked as healthy, while timeouts or other status codes trigger a failure alert on your dashboard.
app.use(statusMonitor({
healthChecks: [
{
protocol: 'http',
host: 'localhost',
path: '/api/internal/health',
port: '3000',
},
{
protocol: 'https',
host: 'api.stripe.com',
path: '/v1/ping',
port: '443',
},
],
}));
🔒 Securing the Dashboard in Production
You should absolutely protect your /status route in production. The middleware exposes a pageRoute handler that easily wraps around your existing authentication strategies.
Example using http-auth (Basic Auth):
const auth = require('http-auth');
const basic = auth.basic({ realm: 'Monitor Area' }, (user, pass, callback) => {
callback(user === 'admin' && pass === 'supersecret');
});
const statusMonitor = require('express-status-monitor-plus')({ path: '' });
app.use(statusMonitor.middleware);
app.get('/status', basic.check(statusMonitor.pageRoute));🔌 Custom Socket.io Instances
If your application already leverages WebSockets, pass your existing Socket.io instance to prevent port conflicts and reuse your existing upgrade handlers.
const http = require('http');
const { Server } = require('socket.io');
const express = require('express');
const app = express();
const server = http.createServer(app);
const io = new Server(server);
app.use(require('express-status-monitor-plus')({
websocket: io,
port: 3000,
}));
🛠 Development
# Install dependencies
npm install
# Build assets (Rollup: JS + CSS + HTML → dist/)
npm run build
# Start dev server with live reload
npm run dev
# Watch mode (rebuild on file changes)
npm run build:watch
# Run tests
npm test
# Lint
npm run lint