Giter Site home page Giter Site logo

phongdh29 / alertmanager-webhook-telegram-python Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nopp/alertmanager-webhook-telegram-python

0.0 0.0 0.0 76 KB

Simple webhook - Alertmanager to telegram (python version)

Shell 18.96% Python 66.36% Dockerfile 14.68%

alertmanager-webhook-telegram-python's Introduction

Alertmanager webhook for Telegram (Python Version)

Docker Image CI Code scanning - action

GO Version (https://github.com/nopp/alertmanager-webhook-telegram-go)

Python version 3

INSTALL

  • pip install -r requirements.txt

Change on flaskAlert.py

  • botToken
  • chatID

If you'll use with authentication, change too

  • XXXUSERNAME
  • XXXPASSWORD

Disabling authentication

On flaskAlert.py change app.config['BASIC_AUTH_FORCE'] = True to app.config['BASIC_AUTH_FORCE'] = False

Alertmanager configuration example

receivers:
- name: 'telegram-webhook'
  webhook_configs:
  - url: http://ipFlaskAlert:9119/alert
    send_resolved: true
    http_config:
      basic_auth:
	username: 'admin'
	password: 'password'

One way to get the chat ID

  1. Access https://web.telegram.org/
  2. Click to specific chat to the left
  3. At the url, you can get the chat ID(Ex: https://web.telegram.org/#/im?p=g1234567, so the chatID is 1234567)

Running

  • python flaskAlert.py

Running on docker

git clone https://github.com/nopp/alertmanager-webhook-telegram.git
cd alertmanager-webhook-telegram/docker/
docker build -t alertmanager-webhook-telegram:1.0 .

docker run -d --name telegram-bot \
	-e "bottoken=telegramBotToken" \
	-e "chatid=telegramChatID" \
	-e "username=<username>" \
	-e "password=<password>" \
	-p 9119:9119 alertmanager-webhook-telegram:1.0

Example to test

curl -XPOST --data '{"status":"resolved","groupLabels":{"alertname":"instance_down"},"commonAnnotations":{"description":"i-0d7188fkl90bac100 of job ec2-sp-node_exporter has been down for more than 2 minutes.","summary":"Instance i-0d7188fkl90bac100 down"},"alerts":[{"status":"resolved","labels":{"name":"olokinho01-prod","instance":"i-0d7188fkl90bac100","job":"ec2-sp-node_exporter","alertname":"instance_down","os":"linux","severity":"page"},"endsAt":"2019-07-01T16:16:19.376244942-03:00","generatorURL":"http://pmts.io:9090","startsAt":"2019-07-01T16:02:19.376245319-03:00","annotations":{"description":"i-0d7188fkl90bac100 of job ec2-sp-node_exporter has been down for more than 2 minutes.","summary":"Instance i-0d7188fkl90bac100 down"}}],"version":"4","receiver":"infra-alert","externalURL":"http://alm.io:9093","commonLabels":{"name":"olokinho01-prod","instance":"i-0d7188fkl90bac100","job":"ec2-sp-node_exporter","alertname":"instance_down","os":"linux","severity":"page"}}' http://username:password@flaskAlert:9119/alert

alertmanager-webhook-telegram-python's People

Contributors

cdpb avatar mator avatar nopp avatar papko26 avatar sajadorouji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.