ix-ai / alertmanager-telegram-bot

This project is deprecated! Please look at alertmanager-notifier, which is a drop-in replacement.

Home Page:https://gitlab.com/ix.ai/alertmanager-notifier

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DEPRECATED

This project is deprecated! Please look at alertmanager-notifier, which is a drop-in replacement. Hence, this project is archived.

alertmanager-telegram-bot

Pipeline Status Docker Stars Docker Pulls Gitlab Project

A simple webserver in Flask, that translates alertmanager alerts into telegram messages.

Running a simple test:

docker run --rm -it \
    -p 9999:9999 \
    -e TELEGRAM_TOKEN="your token" \
    -e TELEGRAM_CHAT_ID="your chat id" \
    -e PORT=9999 \
    -e GELF_HOST=graylog \
    --name alertmanager-telegram-bot \
    registry.gitlab.com/ix.ai/alertmanager-telegram-bot:v0.6.0

Alterantively, use the hub.docker.com image:

docker run --rm -it \
    -p 9999:9999 \
    -e TELEGRAM_TOKEN="your token" \
    -e TELEGRAM_CHAT_ID="your chat id" \
    -e PORT=9999 \
    -e GELF_HOST=graylog \
    --name alertmanager-telegram-bot \
    ixdotai/alertmanager-telegram-bot:latest

Run the test agains the bot:

curl -X POST -d '{"alerts": [{"status":"Testing alertmanager-telegram-bot", "labels":[], "annotations":[], "generatorURL": "http://localhost"}]}' -H "Content-Type: application/json" localhost:9119/alert

Configure alertmanager:

route:
  receiver: 'telegram alerts'
  routes:
    - receiver: 'telegram-webhook'

receivers:
  - name: 'telegram-webhook'
    webhook_configs:
      - url: http://alertmanager-telegram-bot:9119/alert

Supported environment variables:

Variable Default Mandatory Description
TELEGRAM_TOKEN - YES see the Telegram documentation how to get a new token
TELEGRAM_CHAT_ID - YES see this question on stackoverflow
LOGLEVEL INFO NO Logging Level
GELF_HOST - NO if set, the exporter will also log to this GELF capable host on UDP
GELF_PORT 12201 NO Ignored, if GELF_HOST is unset. The UDP port for GELF logging
PORT 9119 NO The port for prometheus metrics
ADDRESS * NO The address for the bot to listen on
TEMPLATE notify.html.j2 NO The template file to be used when creating the telegram message

Templating

alertmanager-telegram-bot supports jinja templating. take a look at templates/notify.html.j2 for that. If you want to use your own template, mount it as a volume in docker and set the TEMPLATE environment variable. The mount path should be under /templates/ (for example /templates/my-amazing-template).

Tags and Arch

Starting with version v0.6.1, the images are multi-arch, with builds for amd64, arm64, armv7 and armv6.

  • vN.N.N - for example v0.6.0
  • latest - always pointing to the latest version
  • dev-branch - the last build on a feature/development branch
  • dev-master - the last build on the master branch

Resources:

Credits:

This work is inspired by nopp/alertmanager-webhook-telegram

About

This project is deprecated! Please look at alertmanager-notifier, which is a drop-in replacement.

https://gitlab.com/ix.ai/alertmanager-notifier

License:MIT License


Languages

Language:Python 87.2%Language:Dockerfile 7.5%Language:Shell 5.3%