cmm-healthcheck
v1.0.4
Published
healthcheck for api integration.
Downloads
16
Readme
Cmm Health Check
Usage
Code
const mongoose = require('mongoose')
const { healthCheck, HealthTypes } = require('cmm-healthcheck')
const Redis = require('ioredis')
const redis = new Redis('REDIS_PORT', 'REDIS_HOST')
healthCheck({
logger: this.logger,
integrations: [
{
type: HealthTypes.Web,
name: 'my web api integration',
host: 'http://validurl.com/healthcheck',
params: {
access_token: 'token'
}
},
{
type: HealthTypes.Mongo,
mongoose
},
{
type: HealthTypes.Axios,
name: 'my axios client',
axiosClient: this.axiosClient,
host: '/accounts'
},
{
type: HealthTypes.Redis,
name: 'redis',
redis,
},
{
type: HealthTypes.Rabbitmq,
name: 'rabbitmq',
host: 'amqp://host:host@rabbitmq',
critical: false
}
]
})
.then(function(result){
console.log(result);
/*
{
"uptime": 750.86376575,
"healthy": true,
"services": [{
name: 'my web api integration',
"healthy": true,
"response_time": 1.86,
"url": "http://validurl.com/healthcheck",
"critical": true
},
{
"name": "mongo",
"healthy": true,
"critical": true
},
{
"name": "my web axios integration",
"healthy": true,
"response_time": 0.652,
"url": "/accounts",
"critical": true
},
{
"name": "redis",
"healthy": true,
"critical": true
},
{
"name": "rabbitmq",
"healthy": false,
"error": {
"errno": -111,
"code": "ECONNREFUSED",
},
"critical": false
}
]
}
*/
})