6

How to create a Grafana bot for Telegram · GitHub

 1 year ago
source link: https://gist.github.com/dl6nm/c312acbc6fddf1a56d749e045f040ca3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

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. e.g. Grafana Bot
  6. Type your bots username. e.g. a_new_grafana_bot
  7. You get your Bot API Token. Paste it on Grafana.
  8. Before making getUpdates (in the next step) you should add your bot into your telegram client and run /start. Thus you start chatting with the bot and this room is assigned chat id. (Thanks to @KES777)
  9. Open this URL address, substituing YOUR_API_TOKEN_KEY with yours: https://api.telegram.org/bot<YOUR_API_TOKEN_KEY>/getUpdates
  10. 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.
  11. Paste it on Grafana.
  12. Test it click on Send Test. You can test it using Telegram API too, just substitute the 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


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK