alertgram

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2019 License: Apache-2.0

README

Alertgram Build Status Go Report Card

Alertgram is the easiest way to forward alerts to Telegram (Supports Prometheus alertmanager alerts).

alertgram

Introduction

Everything started as a way of forwarding Prometheus alertmanager alerts to Telegram because the solutions that I found where too complex, I just wanted to forward alerts to channels without trouble. And Alertgram is just that, a simple app that forwards alerts to Telegram groups and channels.

Input alerts

Alertgram is developed in a decoupled way so in a future may be extended to more inputs apart from Alertmanager's webhook API (ask for a new input if you want).

Options

Use --help flag to show the options.

The configuration of the app is based on flags that also can be set as env vars prepending ALERTGRAM to the var. e.g: the flag --telegram.api-token would be ALERTGRAM_TELEGRAM_API_TOKEN. You can combine both, flags have preference.

Run

To forward alerts to Telegram the minimum options that need to be set are --telegram.api-token and --telegram.chat-id

Simple example
docker run -p8080:8080 -p8081:8081 slok/alertgram:latest --telegram.api-token=XXXXX --telegram.chat-id=YYYYY
Production

Metrics

The app comes with Prometheus metrics, it measures the forwarded alerts, HTTP requests, errors... with rate and latency.

By default are served on /metrics on 0.0.0.0:8081

Development and debugging

You can use the --notify.dry-run to show the alerts on the terminal instead of forwarding them to telegram.

Note that the required options are required, so I would suggest to do this before starting to develop with dry-run mode:

export ALERTGRAM_TELEGRAM_API_TOKEN=fake
export ALERTGRAM_TELEGRAM_CHAT_ID=1234567890

Also remember that you can use --debug flag.

FAQ

Can I use custom template?

Yes!, use the flag --notify.template-path. You can check testdata/templates for examples.

The templates are HTML Go templates with Sprig functions, so you can use these also.

You can use also the notification dry run mode to check your templates without the need to notify on telegram:

export ALERTGRAM_TELEGRAM_API_TOKEN=fake
export ALERTGRAM_TELEGRAM_CHAT_ID=1234567890

go run ./cmd/alertgram/ --notify.template-path=./testdata/templates/simple.tmpl --debug --notify.dry-run

To send an alert easily and check the template rendering without an alertmanager, prometheus, alerts... you can use the test alerts that are on testdata/alerts:

curl -i http://127.0.0.1:8080/alerts -d @./testdata/alerts/base.json

Directories

Path Synopsis
cmd
alertgram command
internal
log
mocks
Package mocks will have all the mocks of the app.
Package mocks will have all the mocks of the app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL