ahmadalli / alertmanager-notifier

A notifier for alertmanager, written in python. It supports multiple notification channels and new ones can be easily added

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

alertmanager-notifier

Pipeline Status Docker Stars Docker Pulls Gitlab Project

A notifier for alertmanager, written in python. It supports multiple notification channels and new ones can be easily added.

Running a simple test:

docker run --rm -it \
    -p 8899:8899 \
    -e TELEGRAM_TOKEN="your token" \
    -e TELEGRAM_CHAT_ID="your chat id" \
    -e GOTIFY_URL="https://gotify" \
    -e GOTIFY_TOKEN="your gotify token" \
    -e EXCLUDE_LABELS="yes" \
    --name alertmanager-notifier \
    registry.gitlab.com/ix.ai/alertmanager-notifier:latest

Run the test agains the bot:

curl -X POST -d '{"externalURL": "http://foo.bar/", "receiver": "alertmanager-notifier-webhook", "alerts": [{"status":"Testing alertmanager-notifier", "labels":{}, "annotations":{}, "generatorURL": "http://foo.bar"}]}' -H "Content-Type: application/json" localhost:8899/alert

Configure alertmanager:

route:
  receiver: 'alertmanager webhook'
  routes:
    - receiver: 'alertmanager-notifier-webhook'

receivers:
  - name: 'alertmanager-notifier-webhook'
    webhook_configs:
      - url: http://alertmanager-notifier:8899/alert

Supported environment variables:

Variable Default Description
TELEGRAM_TOKEN - see the Telegram documentation how to get a new token
TELEGRAM_CHAT_ID - see this question on stackoverflow
TELEGRAM_TEMPLATE html.j2 allows you to specify another (HTML) template, in case you've mounted it under /templates
TELEGRAM_TEMPLATE_TOO_LONG too_long.html.j2 allows you to specify another (HTML) template for Telegram, for the case that the message size exceeds the maximum message size (4096 characters)
TELEGRAM_MAX_RETRIES 0 The maximum number of times an alert should be tried to be sent out (0 for unlimited)
TELEGRAM_ALWAYS_SUCCEED no Set this variable to yes so that alertmanager-notifier always sends a 200 OK to alertmanager, even if the Telegram notification wasn't successful
 GOTIFY_URL - the URL of the Gotify server
GOTIFY_TOKEN - the APP token for Gotify
GOTIFY_TEMPLATE markdown.md.j2 allows you to specify another (HTML) template, in case you've mounted it under /templates
EXCLUDE_LABELS yes  set this to no to include the labels from the notifications
LOGLEVEL INFO Logging Level
GELF_HOST - If set, the exporter will also log to this GELF capable host on UDP
GELF_PORT 12201 Ignored, if GELF_HOST is unset. The UDP port for GELF logging
PORT 8899 the port for incoming connections
ADDRESS * the address for the bot to listen on

NOTE: If no notifier is configured, the Null notifier will be used and the notification will only be logged

Gotify Priority

Gotify supports message priorities, that are also mapped to Android Importance (see gotify/android#18).

If you set the annotation priority to your alert, with a number as value, this will be passed through to gotify.

Note: Since alertmanager supports sending multiple alerts in one message, alertmanager-notifier will always use the highest priority value for gotify from the batch.

Templating

alertmanager-notifier supports jinja templating. take a look in the templates/ folder for examples 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

The images are multi-arch, with builds for amd64, arm64, armv7 and armv6.

  • vN.N.N - for example v0.0.1
  • latest - always pointing to the latest version
  • dev-master - the last build on the master branch

Images:

  • Docker Hub: ixdotai/alertmanager-notifier
  • Gitlab Registry: registry.gitlab.com/ix.ai/alertmanager-notifier

Resources:

About

A notifier for alertmanager, written in python. It supports multiple notification channels and new ones can be easily added

https://ix.ai/alertmanager-notifier

License:MIT License


Languages

Language:Python 74.7%Language:HTML 18.4%Language:Dockerfile 3.9%Language:Shell 3.0%