Introducing Koinos Node Monitor: A Vital Tool for Monitoring Node Uptime

The Koinos Node Monitor is a vital tool for block producers, providing real-time alerts to ensure your node stays online and operational. Learn how to set up notifications via Telegram and Discord and keep your Koinos node running smoothly.

Introducing Koinos Node Monitor: A Vital Tool for Monitoring Node Uptime
Koinos Node Monitor - A Vital Tool for Monitoring Node Uptime

As a block producer on the Koinos blockchain, maintaining node uptime is essential. Downtime can lead to missed rewards, reduced credibility, and interruptions in the block production process. To help block producers keep their nodes running smoothly, I’ve developed the Koinos Node Monitor — a simple yet effective monitoring tool that alerts you whenever your node is in trouble.

Quickly Detect Downtime: receive Discord + Telegram alerts if your node stops producing blocks, helping you react before it becomes critical.

This tool checks if your node has been producing blocks within a specified threshold and sends notifications to Telegram and Discord channels if any issues arise. Let’s walk through how the monitor works and how to set up Telegram and Discord notifications.

Key Features of Koinos Node Monitor

  • Automated Checks: The monitor automatically checks the node’s block production status every 15 seconds (fully customizable), so you always know if your node is functioning correctly.
  • Adjustable Downtime Threshold: Configure the threshold time for downtime detection based on your needs. By default, the monitor triggers an alert if no blocks are produced for 1 minute.
  • Escalating Alerts: An escalating alert system adjusts the alert frequency based on the duration of the downtime, with notifications sent every 2 minutes initially, then gradually spacing out to every hour. This ensures timely updates without overwhelming you with alerts.
  • Flexible Notification Channels: Set up notifications through both Telegram and Discord to stay informed on the platform of your choice.
  • Docker-Ready: Fully compatible with Docker, making it simple to deploy and integrate into your existing Koinos Node setup.

Let’s go through the steps to set up the Koinos Node Monitor and configure Telegram and Discord notifications.


Setting Up Telegram Notifications

Receive Telegram notifications when you Koinos Node goes down

To receive notifications on Telegram, follow these steps:

Step 1: Create a Telegram Bot

  1. Open Telegram and search for the BotFather bot (@BotFather).
  2. Start a conversation with BotFather and use the /newbot command to create a new bot.
  3. Follow the instructions to name your bot and create a unique username.
  4. Save the bot token provided by BotFather. You’ll need this token to set up notifications, so add it to your environment variables as TELEGRAM_API_KEY.

Step 2: Add the Bot to Your Channel

  1. Create a Telegram channel (or use an existing one).
  2. Add your bot as an admin in the channel. This step is crucial because the bot needs admin rights to post messages.

Step 3: Get the Channel ID

You’ll need your channel’s ID to send messages to it. Here’s how to get it:

  1. If your channel has a username (e.g., @your_channel_name), you can use that as the TELEGRAM_CHAT_ID inside the .env file.
  2. If the channel doesn’t have a username, send a test message in the channel and use the Telegram Bot API’s getUpdates method to get the chat ID:curl "https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates".
  3. In the response, find chat.id (starting with -100) and use it as your TELEGRAM_CHAT_ID.

Setting Up Discord Notifications

Receive Discord notifications when you Koinos Node goes down

To receive notifications on Discord, follow these steps:

  1. Create a Discord server (or use an existing one).
  2. Create a channel where you want to receive the notifications.
  3. Go to Server Settings > Integrations > Webhooks.
  4. Create a new webhook, give it a name, and select the channel you want it to post to.
  5. Copy the Webhook URL and add it to your environment variables as DISCORD_WEBHOOK_URL.
Create a webhook within Discord to receive Discord notifications

Environment Variables

Add these variables to the .env file in your project directory to configure the Koinos Node Monitor:

MONITOR_TAG=v0.1.0
TELEGRAM_API_KEY=your_telegram_bot_token
TELEGRAM_CHAT_ID=your_telegram_channel_id
DISCORD_WEBHOOK_URL=your_discord_webhook_url
NODE_NAME=My Koinos Node

Optionally you can override the following variables in your .env file:

CRON_INTERVAL='*/15 * * * * *'
THRESHOLD_TIME=60000

Make sure to include monitor and jsonrpc in COMPOSE_PROFILES when you are using COMPOSE_PROFILES.

COMPOSE_PROFILES=jsonrpc,block_producer,monitor

Explanation of Environment Variables

  • MONITOR_TAG: version of the docker image to use.
  • TELEGRAM_API_KEY: Your Telegram bot token, obtained from BotFather.
  • TELEGRAM_CHAT_ID: The ID or username of your Telegram channel.
  • DISCORD_WEBHOOK_URL: The webhook URL for the Discord channel where you want notifications to appear.
  • JSONRPC_URL: The URL of the Koinos RPC node you’re monitoring.
  • CRON_INTERVAL: Cron interval for node check frequency, defaulting to 15 seconds.
  • THRESHOLD_TIME: The time threshold (in milliseconds) beyond which the node is considered down. Default is 60,000 ms (1 minute).
  • NODE_NAME: The name of the node, which will appear in alert messages.

Adding the Monitor to Docker Compose

To integrate the Koinos Node Monitor into a Docker Compose setup, add the following example to your docker-compose.yml configuration:

version: '3'
services:
koinos-node-monitor:
image: frenkzcom/koinos-monitor:${MONITOR_TAG:-latest}
restart: always
profiles: ["monitor", "all"]
environment:
- JSONRPC_URL=http://jsonrpc:8080/
env_file:
- '.env'
depends_on:
- jsonrpc

Conclusion

The Koinos Node Monitor is an essential tool for block producers who want to keep a close watch on their node’s uptime. With just a few setup steps, you can start receiving timely notifications whenever your node is at risk of downtime, giving you the chance to act fast and maintain the reliability of your block production operations on the Koinos blockchain.

When running your Koinos node in the cloud, consider deploying the monitor on a separate cloud service to ensure you receive alerts even if the entire node goes offline.

Source code can be find out Github.

Keep your Koinos node resilient and printing $KOIN! 🚀