This is a simple microservice health checker package built in Node.js. It allows you to monitor the health of various microservices by periodically sending HTTP requests to their health endpoints and logging the results.
- Configurable health check intervals.
- Supports multiple services.
- Simple console log reporting.
To install this package, use npm:
npm install microservice-health-checker
First, import and initialize the HealthChecker
with a list of services and the interval between health checks:
const HealthChecker = require('microservice-health-checker');
const services = [
{ name: 'User Service', url: 'http://localhost:3000/health' },
{ name: 'Order Service', url: 'http://localhost:3001/health' }
];
const checker = new HealthChecker(services, 10000); // Checks every 10 seconds
checker.start();
-
services
: An array of objects, each representing a service with aname
and aurl
property. -
interval
: Time in milliseconds between each health check (default is 30000 ms).
Contributions are welcome. Please submit a pull request or open an issue if you have any suggestions or improvements.
This project is licensed under the MIT License - see the LICENSE file for details.