Skip to content

Instantly share code, notes, and snippets.

@terrazz
Forked from dl6nm/Grafana-TelegramBot-HowTo.md
Created August 11, 2022 10:17
Show Gist options
  • Save terrazz/819c667fce6b39eaceca0a57a51fb8f3 to your computer and use it in GitHub Desktop.
Save terrazz/819c667fce6b39eaceca0a57a51fb8f3 to your computer and use it in GitHub Desktop.
How to create a Grafana bot for Telegram

Set up a Telegram Bot

  1. Go to Grafana > Alerting > Notification channels > New channel.
  2. Type: Telegram. It will ask you for a Bot API Token and a Chat ID.
  3. Open a chat with BotFather on Telegram.
  4. Type /newbot
  5. Type your bots name. F.e: Grafana Bot
  6. Type your bots username. F.e: a_new_grafana_bot
  7. You have your Bot API Token. Paste it on Grafana.
  8. Open this URL address, substituing YOUR_API_TOKEN_KEY with yours: https://api.telegram.org/bot<YOUR_API_TOKEN_KEY>/getUpdates
  9. The response may look like this: {"ok":true,"result":[{"update_id":BLA_BLA_BLA", chat":{"id":[CHAT_ID],"title". Copy that CHAT_ID, even with the minus sign.
  10. Paste it on Grafana.
  11. Test it click on "Send Test". You can test it using Telegram API too, just substitute parameters with your API Token and Chat ID: https://api.telegram.org/botYOUR_API_TOKEN/sendMessage?chat_id=YOUR_CHAT_ID&text=a_message

Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment