Sign inSign up

ultram4rine/alerter

By ultram4rine

•Updated over 4 years ago

Telegram and Matrix bot for alerts from Alertmanager

Image
0

1.5K

ultram4rine/alerter repository overview

⁠Alerter

Crates.io Docker Image Size (latest by date) GitHub Workflow Status

Telegram and Matrix bot for alerts from Alertmanager⁠

⁠Usage

⁠Telegram preparations
  1. Create bot with BotFather⁠ and get token.

  2. Get your, group or channel chat id with Get My ID⁠ bot.

⁠Matrix preparations
  1. Create user under which alerter will work.

  2. Add this user to room for alerts and get room_id.

After preparations:

  1. Configure⁠ alerter.

  2. Optionally check that messages are being sent and properly formatted with that script⁠:

    ./test.sh tg
    

    Or

    ./test.sh matrix
    
  3. Add alerter to receivers in your alertmanager.yml:

    receivers:
      - name: alerter_tg
        webhook_configs:
          - send_resolved: true
            url: "http://127.0.0.1:3030/tg"
      - name: alerter_matrix
        webhook_configs:
          - send_resolved: true
            url: "http://127.0.0.1:3030/matrix"
    
⁠Templating

You can modify default templates for your needs, they are in Handlebars⁠ format. For Telegram alerter uses HTML⁠ style and for Matrix Markdown⁠ style.

⁠Installation

⁠Prebuilt packages

You can download prebuilt archive or Deb/RPM package from releases⁠.

⁠Docker

Pull image from DockerHub⁠:

docker pull ultram4rine/alerter

In other cases, you need Rust⁠ installed.

⁠Crates.io

You can install alerter from crates.io⁠:

cargo install alerter

Then download needed template⁠ and run.

⁠Build from source
  1. Clone repository:

    git clone https://github.com/ultram4rine/alerter.git
    cd alerter
    
  2. Build binary:

    cargo build --release
    
  3. Binary should be in target/release/alerter.

⁠Build Deb or RPM package

See cargo-deb⁠ or cargo-generate-rpm⁠ instructions respectively.

⁠Configuration

Use environment variables or command-line flags to configure alerter:

Environment variableCommand-line flagDefaultDescription
ALERTER_LISTEN_PORT--port (-p)3030Port to listen.
--tgEnable Telegram support.
ALERTER_TG_BOT_TOKEN--tg-tokenTelegram bot token. Required for Telegram support.
ALERTER_TG_CHAT_ID--tg-chat-idTelegram chat ID. Required for Telegram support.
ALERTER_TG_TMPL_PATH--tg-template-pathtemplates/default.tg.hbsPath to handlebars template file. Required for Telegram support.
--matrixEnable Matrix support.
ALERTER_MATRIX_USERNAME--matrix-userMatrix username. Required for Matrix support.
ALERTER_MATRIX_PASSWORD--matrix-passMatrix password. Required for Matrix support.
ALERTER_MATRIX_ROOM_ID--matrix-room-idMatrix room id. Required for Matrix support.
ALERTER_MATRIX_TMPL_PATH--matrix-template-pathtemplates/default.matrix.hbsPath to handlebars template file for Matrix. Required for Matrix support.

Tag summary

Content type

Image

Digest

Size

36.5 MB

Last updated

over 4 years ago

docker pull ultram4rine/alerter