
Overview
Grafana is great but unless you are going to stare at monitoring panels all day and night then you might want to get some alerts. I’ve found a nice way (and free way) to setup effectively a webhook to Telegram.
Setup Telegram and Grafana Alerts
1. In Telegram search for Botfather
2. Issue the “/newbot” command
3. Enter a name for the bot
4. Enter a username for the bot
The bot will issue a API token
Add that API token to the “BOT API Token” part of Grafana alerts
5. Open a new message to the bot and type “/start”
6. Issue the following curl statement in any web browser
Replace “<TOKEN>” with the API token
https://api.telegram.org/bot/getUpdates
Example return
{"ok":true,"result":[{"update_id":123456789,
"message":{"message_id":1,"from":{"id":1234567890,"is_bot":false,"first_name":"FIRSTNAME","last_name":"LASTNAME","language_code":"en"},
"chat":{"id":1234567890,"first_name":"FIRSTNAME","last_name":"LASTNAME","type":"private"},"date":1591782293,"text":"/start","entities":[{"offset":0,
"length":6,"type":"bot_command"}]}}]}
Add the id to the “Chat ID” part of Grafana alerts
7. Save and test

Example Telegram Alerts
So I’ve masked out a lot of detail but you get the idea

Example Grafana Alert
This is where a lot of tweaking is required to get your alert to only trigger when required, the biggest help with this is the “Test Rule” at the bottom which gives you the current value.

Leave a Reply