All Projects → gritzkoo → nodejs-health-checker

gritzkoo / nodejs-health-checker

Licence: MIT license
This is a Node package that allows you to track the health of your application providing readiness and liveness functionalities.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nodejs-health-checker

golang-health-checker
A simple package to allow you to track your application healthy
Stars: ✭ 12 (-64.71%)
Mutual labels:  healthcheck, health-check, k8s, liveness-probe, readiness-probe, hacktoberfest2020
ngx stream upstream check module
nginx health checker (tcp/udp/http) for stream upstream servers.
Stars: ✭ 18 (-47.06%)
Mutual labels:  healthcheck, health-check
frontatish
A React native common components kit and helper methods,find the package at this link https://www.npmjs.com/package/frontatish
Stars: ✭ 14 (-58.82%)
Mutual labels:  npm-package, hacktoberfest2020
microservice-graph-explorer
Navigate and explore all of the microservices in your application in real time using the real application connections.
Stars: ✭ 71 (+108.82%)
Mutual labels:  healthcheck, health-check
aarogya seva
A beautiful 😍 covid-19 app with self - assessment and more.
Stars: ✭ 118 (+247.06%)
Mutual labels:  healthcheck, health-check
EverydayFun
A simple NPM package which can return everyday quotes, jokes, riddles and interesting facts!
Stars: ✭ 35 (+2.94%)
Mutual labels:  npm-package, hacktoberfest2020
quark
An open source framework to build competitive platforms
Stars: ✭ 35 (+2.94%)
Mutual labels:  hacktoberfest2020
youtrack-cli
Command Line Tool for interacting with youtrack
Stars: ✭ 14 (-58.82%)
Mutual labels:  npm-package
kubernetes-workshop
Kubernetes Workshop
Stars: ✭ 20 (-41.18%)
Mutual labels:  k8s
terraform-provider-carvel
Carvel Terraform provider with resources for ytt and kapp to template and deploy to Kubernetes
Stars: ✭ 40 (+17.65%)
Mutual labels:  k8s
tezos-k8s
Deploy a Tezos Blockchain on Kubernetes
Stars: ✭ 43 (+26.47%)
Mutual labels:  k8s
watcher
watcher(守望者)提供java应用暴露监控/健康检查的能力。
Stars: ✭ 65 (+91.18%)
Mutual labels:  healthcheck
Hacktoberfest-2021
Make this Hacktoberfest a learning period and contribute to Great Open Source Projects.
Stars: ✭ 523 (+1438.24%)
Mutual labels:  hacktoberfest2020
personal-dj
Personal DJ site that creates playlists given custom inputs. View it live at: http://personaldj.net/
Stars: ✭ 27 (-20.59%)
Mutual labels:  hacktoberfest2020
hex-rgba
Convert HEX to RGBA
Stars: ✭ 12 (-64.71%)
Mutual labels:  npm-package
kube-lineage
A CLI tool to display all dependencies or dependents of an object in a Kubernetes cluster.
Stars: ✭ 238 (+600%)
Mutual labels:  k8s
noobtoberfest
Game-coding challenge for everyone who wants to contribute to an open-source project for Hacktoberfest 2020 🎮
Stars: ✭ 32 (-5.88%)
Mutual labels:  hacktoberfest2020
aws-api-read-stream
Turn an AWS api call into a readable stream
Stars: ✭ 24 (-29.41%)
Mutual labels:  npm-package
hacktoberfest-2020
Let's tackle the Climate-Change together with Open-Source 🌍 + 👩‍💻
Stars: ✭ 23 (-32.35%)
Mutual labels:  hacktoberfest2020
Quizller
Quizller is a php based open source web application to create and manage online quiz, test, exam.
Stars: ✭ 41 (+20.59%)
Mutual labels:  hacktoberfest2020

nodejs-health-checker

npm
npm version test GitHub Workflow Status (event) Coverage Status License Status Issues Status Tag Status Languages Status Repo Size Status

This is a Node package that allows you to track the health of your application, providing two ways of checking:

Simple: will respond to a JSON as below and that allows you to check if your application is online and responding without checking any kind of integration.

{
  "status": "fully functional"
}

Detailed: will respond a JSON as below and that allows you to check if your application is up and running and check if all of your integrations informed in the configuration list is up and running.

{
    "name": "My node application",
    "version": "my version",
    "status": true,
    "date": "2020-09-18T15:29:41.616Z",
    "duration": 0.523,
    "integrations": [
        {
            "name": "redis integration",
            "kind": "Redis DB integration",
            "status": true,
            "response_time": 0.044,
            "url": "redis:6379"
        },
        {
            "name": "My memcache integration",
            "kind": "Memcached integraton",
            "status": true,
            "response_time": 0.038,
            "url": "memcache:11211"
        },
        {
            "name": "my web api integration",
            "kind": "Web integrated API",
            "status": true,
            "response_time": 0.511,
            "url": "https://github.com/status"
        },
        {
            "name": "my dynamo",
            "kind": "AWS Dynamo DB",
            "status": true,
            "response_time": 0.004,
            "url": "http://localhost:8000",
        }
    ]
}

How to install

npm i nodejs-health-checker

Available integrations

  • Redis
  • Memcached
  • Web integration (https)
  • AWS DynamoDB
  • Sequelize (authored by @MikeG96)
  • Custom integration support (authored by @youngpayters)

How to use

Example using Nodejs + Express

import express from "express";
import {
  HealthcheckerDetailedCheck,
  HealthcheckerSimpleCheck
} from "./healthchecker/healthchecker";
import { Dialects, HealthTypes } from "./interfaces/types";

const server = express();

server.get("/health-check/liveness", (_, res) => {
  res.send(HealthcheckerSimpleCheck());
});

server.get("/health-check/readiness", async (_, res) => {
  res.send(
    await HealthcheckerDetailedCheck({
      name: "My node application",
      version: "my version",
      // here you will inform all of your external dependencies
      // that your application must be checked to keep healthy
      // available integration types: [
      //   HealthTypes.Redis,
      //   HealthTypes.Memcached,
      //   HealthTypes.Web
      //   HealthTypes.Custom
      // ]
      integrations: [
        {
          type: HealthTypes.Redis,
          name: "redis integration",
          host: "redis",
        },
        {
          type: HealthTypes.Memcached,
          name: "My memcache integration",
          host: "memcache:11211",
        },
        {
          type: HealthTypes.Web,
          name: "my web api integration",
          host: "https://github.com/status",
          headers: [{ key: "Accept", value: "application/json" }],
        },
        {
          type: HealthTypes.Dynamo,
          name: "my dynamo",
          host: "http://localhost",
          port: 8000,
          Aws: {
            region: "us-east-1",
            access_key_id: "",
            secret_access_key: "",
          },
        },
        {
          type: HealthTypes.Database,
          name: "my database",
          host: "localhost",
          dbPort: 5432,
          dbName: "postgres",
          dbUser: "postgres",
          dbPwd: "root",
          dbDialect: Dialects.postgres,
        },
        {
          type: HealthTypes.Custom,
          name: "my custom integration",
          host: "localhost",
          customCheckerFunction: () => { return { status: true, error: {} }},
        },
      ],
    })
  );
});

export default server;

And then, you could call these endpoints manually to see your application health, but, if you are using modern Kubernetes deployment, you can config your chart to check your application with the setup below. There is an Example on runkit too.

apiVersion: v1
kind: Pod
metadata:
  labels:
    test: liveness
  name: liveness-http
spec:
  containers:
  - name: liveness
    image: 'node' #your application image
    args:
    - /server
    livenessProbe:
      httpGet:
        path: /health-check/liveness
        port: 80
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3
  - name: readiness
    image: 'node' #your application image
    args:
    - /server
    readinessProbe:
      httpGet:
        path: /health-check/readiness
        port: 80
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 3
      periodSeconds: 3

Import using require

If your application needs to use the require instead of ECMAScript, you should import on this way:

const express = require('express');
const {
    HealthcheckerSimpleCheck,
    HealthcheckerDetailedCheck
} = require("nodejs-health-checker/dist/healthchecker/healthchecker");
const { HealthTypes } = require("nodejs-health-checker/dist/interfaces/types");
const server = express();
server.get('/', (req, res) => {
    res.json({ status: "I'm alive!" });
})
server.get('/health-check/liveness', (req, res) => {
    res.json(HealthcheckerSimpleCheck())
})
server.get('/health-check/readiness', async (req, res) => {
    let result = await HealthcheckerDetailedCheck({
        name: 'example',
        version: 'v1.0.0',
        integrations: [
            {
                type: HealthTypes.Web,
                name: 'A simple api integration check',
                host: 'https://github.com/status'
            }
        ]
    });
    res.json(result);
})
server.listen(3000, () => {
    console.log('server started at port 3000')
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].