• Public
  • Public/Protected
  • All

AlertManager Telegram Bot

Alertmanager telegram bot

Yet another Prometheus alertmanager's telegram bot

GitHub license GitHub top language GitHub repo size Docker Image Size (latest by date)

CII Best Practices GitHub last commit Build

Maintainability Test Coverage Code Climate issues

This is a work in progress, so take all functionalities with a grain of salt.

You can also jump directly to the docs.

Table of Contents


A bot that uses some fancy features from telegram as inline keyboards and replies to messages instead of the boring slash commands.

Getting Started

You can setup the bot using those environment variables:

variable default description
TELEGRAM_ADMINS undefined comma-separated telegram user IDs, which the bot will talk to
TELEGRAM_TOKEN undefined your bot token
TEMPLATE_FILE default.tmpl template file path to use for messages
EXTERNAL_URL endpoint to register the webhook on Telegram (useful for reversed-proxy deployments)
INTERNAL_URL undefined alertmanager URL to send API requests (default: uses externalURL provided on the alert)
ALERTMANAGER_DB_PATH data/alertmanager database path for alertmanager graph storage (LevelGraph)
ALERTS_DB_PATH data/alerts database path for alert storage (LevelDB)


If running locally, nodejs and yarn, and install all dependencies:

yarn install

Otherwise you can use docker:

docker build -t wwmoraes/alertmanager-telegram-bot .

message template

For formatting messages the bot uses doT + a linebreak replacement. You can provide a custom template file by mounting your file as a volume + setting the path on TEMPLATE_FILE. All br HTML tags will be replaced by line breaks.

using it as a module on another bot

The alertmanager logic is also available as a Telegraf module to be used on other bots. You can do so with

import {
} from "./AlertManager";

interface YourBotContext extends AlertManagerContext {}

const bot = new Telegraf<YourBotContext>("your-bot-token");




yarn start


docker run --rm -it --env-file=.env -p 8443:8443 wwmoraes/alertmanager-telegram-bot

The bot itself is very straightforward, and does most of the actions using inline keyboards. You can enroll yourself to receive the AM alerts using /start 😄

Slash commands

The alertmanager middleware uses no slash commands, and instead automatically registers the given user IDs to receive notifications.

If using the full bot from this repository, then you can use:

  • /start - registers yourself to receive the alerts
  • /help - well, halp 😂

It also responds to hi and stickers as a "health check".

Generated using TypeDoc