Crerate Telegrambot
- Create Telegrambot
Follow the guilde in Telegram docs: https://core.telegram.org/bots#creating-a-new-bot
You will recieve telegram token id. We will store it and use later.
2. Create new group to receive alerts then add bot into group.
Alter bot join to group, you will recieve chat id of group
Chat id is ‘-4xxxxxxxx’
Create and build telegrambot docker image
- Clone Telegram bot source code from github
git clone github.com/inCaller/prometheus_bot
2. Move into source code
cd prometheus_bot/
3. Edit Dockerfile
4. Build docker image
docker build -t tienbm90/prometheus-bot:0.0.1
Configure telegrambot
- Create folder to store telegrambot configuration
mkdir telegrambot
2. Create telegrambot configuration file telegrambot/config.yaml:
3. Define alert format with telegrambot/template.tmpl:
Configure Alertmanager
Alert manager configuration file:
Replace telegram-chat-id
with the number you got from your bot, with -
. To use multiple chats just add more receivers.
Create docker-compose.yml file
Configure prometheus to use alertmanager:
alerting:
alertmanagers:
— static_configs:
— targets:
# Alertmanager’s default port is 9093
— 10.240.183.8:9093
Start alertmanager and telegrambot
docker-compose up -d
Verify and check result
You will recieve message like this:
Type: Host out of memory
Summary: Host out of memory (instance x.x.x.x:y)
Alertname: HostOutOfMemory
Instance: x.x.x.x:y
Serverity: information
Status: firing