Keep a Pulse on Your Backend
Express Insights is a production-ready middleware for comprehensive, real-time health monitoring of your Express.js applications.
Why Choose Express Insights?
Everything you need to maintain a healthy and observable backend service.
System Metrics
Monitor CPU usage, memory, disk space, and network stats in real-time with visualizations.
Custom Health Checks
Extend functionality to monitor databases, APIs, or other services with custom logic.
Prometheus Integration
Export metrics in Prometheus format for seamless observability integration.
Quick & Easy Installation
Get started with just a few commands.
1. Install the Package & Dependencies
npm install express-insights winston validator sanitize-html dotenv check-disk-space
Copied!
2. Install Express (if not installed)
npm install express
Copied!
Simple to Integrate
Add health monitoring with minimal code.
Basic Setup
const express = require('express');
const healthCheck = require('express-insights');
const app = express();
healthCheck(app);
app.listen(3000, () => {
console.log('Server running on port 3000');
console.log('Health check available at /health');
});
Copied!
Advanced Configuration
healthCheck(app, {
route: '/status',
htmlResponse: true,
style: 'dark',
cors: { allowedOrigins: ['https://admin.example.com'] },
authentication: (authHeader) => authHeader === `Bearer ${process.env.SECRET_TOKEN}`,
enableMetrics: true,
includeDisk: true,
includeNetwork: true,
});
Copied!
Live Demo
See express-insights in action with a sample health check response.
Sample Health Check Response
Click "Fetch Data" to see a sample response.
API Reference
Customize express-insights with these configuration options.
| Option | Type | Default | Description |
|---|---|---|---|
| route | string | '/health' | The endpoint for the health check response. |
| htmlResponse | boolean | false | Returns a formatted HTML page instead of JSON. |
| style | string | 'light' | Theme for HTML response ('light' or 'dark'). |
| cors | boolean | object | false | Enable or configure CORS with { allowedOrigins: [...] }. |
| authentication | function | string | null | Validate Authorization header or use a static token. |
| rateLimit | object | null | Rate limit config, e.g., { max: 100, windowMs: 900000 }. |
| enableMetrics | boolean | false | Enables /metrics endpoint for Prometheus. |