Skip to content

Simple node-js healthcheck with alert to telegram messenger.

Notifications You must be signed in to change notification settings

VictorKolb/simple-healthcheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HealthCheck

Simple node-js healthcheck with alert to telegram messenger.

Requirements

  • Node js
  • Docker Compose
  • Telegram bot token (@BotFather can give it)
  • Your telegram id to receive alert (use @jsondumpbot)

Don't forget press 'Start' in bot dialog to accept for bot messages.

Setup

  • Clone the repository
  • In src/config.js set targets array, bot token, your userId and timeInterval:
module.exports = {
  token: "yourbottoken",
  timeInterval: "0 * * * * *",
  userId: 123456789,
  targets: [
    {
      url: "https://example.com/healthcheck",
      name: "Server name one",
      ip: "33.33.33.224",
    },
    {
      url: "https://example2.com/healthcheck1",
      name: "Server name two",
      ip: "33.33.33.224",
    },
  ],
};
  • Run it with docker-compose up --build -d

FAQ

Time interval

For change time interval check node-schedule readme

Healthcheck route

You can use any working url. I use something like this:

import express from "express";

const app = express();

app.get("/healthcheck", (req, res) => {
  const healthcheck = {
    uptime: process.uptime(),
    message: "OK",
    timestamp: Date.now(),
  };

  try {
    res.send(healthcheck);
  } catch (e) {
    healthcheck.message = e;
    res.status(503).send(healthcheck);
  }
});

About

Simple node-js healthcheck with alert to telegram messenger.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published