node-runtime-monitor
v0.1.0
Published
Lightweight Node.js runtime monitoring and observability middleware using perf_hooks and native APIs.
Maintainers
Readme
node-runtime-monitor
Lightweight Node.js runtime monitoring for Express apps.
It collects runtime stats (CPU, memory, process info, GC, and event loop behavior), exposes them as JSON, and provides a simple browser dashboard.
Zero external runtime dependencies in Node.js. The dashboard UI uses only Chart.js loaded from a CDN in src/public/index.html.
Install
npm install node-runtime-monitorQuick start
const express = require('express');
const {
monitor,
metricsHandler,
dashboardHandler,
} = require('node-runtime-monitor');
const app = express();
// Start background metric collection
app.use(monitor({ interval: 5000 }));
// Raw metrics JSON
app.get('/status', metricsHandler);
// Dashboard UI
app.get('/status-dashboard', dashboardHandler({ metricsPath: '/status' }));
app.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});What this package exports
The package exports 3 functions:
monitor(options?): Starts metric collection (once) and returns an Express middleware.options.interval(number, optional): collection interval in milliseconds.- Default:
5000.
metricsHandler(req, res): Express route handler that returns all collected metrics as JSON.dashboardHandler(options?): Returns an Express route handler that serves the built-in dashboard HTML.options.metricsPath(string, optional): endpoint the dashboard should call for metrics.- Default:
/status.
Suggested routes
- JSON metrics:
/status - Dashboard:
/status-dashboard
License
MIT
