Health
Health is a resource status monitoring library.
This is handy when you want to monitor the status of multiple resources using a simple configuration file. For example, if your application requires a web service and a MongoDB database to be available, Health module can monitor those resources and return status ok/fail against each resource along with the response time.
It also supports result caching via ttl attribe of each resource, which is handy when you want to monitor multiple resources at a different interval or to reduce the load on certain resources.
Installation
npm install -g health
Usage
var health = new (require('health'))(
setup: [
{ name: 'google', uri: 'http://google.com' },
{ name: 'gmail', uri: 'https://mail.google.com' }
]
);
Configuration
Health setup is just a simple JSON:
[
{ "name": "google", "uri", "http://google.com", "statusCodes": [ 200 ] },
{ "name": "gmail", "uri", "https://mail.google.com", "timeout": "1000" },
{ "name": "mongodb", "uri": "mongodb://somehost:27017", "timeout": 200, "ttl": 30000 }
]
Attribute | Type | Description | Checker | Usage | Default | Example |
---|
uri | string | Resource URI to check | All | Mandatory | | mongodb://somehost:27017 |
name | string | Resource name | All | Optional | | someapp |
ttl | number | Cache time to live in milliseconds | All | Optional | | 30000 |
timeout | number | Request/connect timeout in milliseconds | http, https, mongodb | Optional | | 500 |
statusCodes | array | An array of acceptable response HTTP status codes, any match means status OK | http, https | Optional | | [ 200, '3xx', 409 ] |
texts | array | An array of all texts that must exist in response body, any of them does not exist means status FAIL | http, https | Optional | | [ 'foo', 'bar' ] |