Telegram Alert Channel configuration

Hi folks, get updated to latest 4.2 release and trying to get Alerts through new Telegram Alert Channel.
There is nothing written in docs and even no information about Telegram: http://docs.grafana.org/alerting/notifications/
So what I did already:

  1. Created a bot via @BotFather, got an API token
  2. Created a group chat and invited the Bot to the channel
    There is to parameters in Telegram Notification Channel options:
  • BOT API Token (Got)

  • Chat ID (???)
    So I have no idea what to type in field named “Chat ID”: tried my @user_name and created channel name with “@” in begining - but nothing works. In Grafana log got this lines:

    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=info msg=“Sending notification” logger=alerting.notifier type=telegram id=0 isDefault=false
    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=info msg=“Sending alert notification to” logger=alerting.notifier.telegram bot_token=bot123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=info msg=“Sending alert notification to” logger=alerting.notifier.telegram chat_id=@user_name
    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=eror msg=“Failed to send webhook” logger=alerting.notifier.telegram error=“Webhook response status 400 Bad Request” webhook="Telegram Alert"
    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=eror msg=“Failed to send alert notifications” logger=context userId=1 orgId=1 uname=admin error="Webhook response status 400 Bad Request"
    мар 24 15:01:44 grafana grafana-server[11223]: t=2017-03-24T15:01:44+0300 lvl=eror msg=“Request Completed” logger=context userId=1 orgId=1 uname=admin method=POST path=/api/alert-notifications/test status=500 remote_addr=“CLASSIFIED_IP, CLASSIFIED_PROXY” time_ms=633ns size=48

1 Like

So I found how it works!!!
0. After bot creation via @BotFather in Telegram App you get the Bot API Token

  1. First thing you need is to create new Chat Group in Telegram App, for example: “Super Dooper Alert Group” with people who need to be alerted.
  2. Invite your bot to this group
  3. Use cURL or just place this on any Browsers Address Bar: https://api.telegram.org/bot<TOKEN>/getUpdates
  4. Previous step should return JSON object, you need to find key “chat” like this one:
    "chat":{"id":-456343576,"title":"Super Dooper Alert Group","type":"group","all_members_are_administrators":true}
  5. You need that number: -456343576 - just place it in according fielld after Bot API Token in Telegram Channel configuration page - and thats all!!!
1 Like

Thanks for describing the flow. We’ll add this to the documentation.

I put that address in with the token and this is all i get in the browser:
{“ok”:true,“result”:[]}

@pdizzle You have to send at least one message using the chatroom. Then you should get a valid JSON.

1 Like

Never mind, it was grafana login issue. got it working
BTW You need to enter the bot ID without bot prefix

Ok so I upgraded to 5.0.4 from 4.x and now you need a bot prefix in the grafana bot token setup

Chat ID:

  1. Go to https://web.telegram.org
  2. Go to your Group and find your link (URL) of Group like (Telegram Web)
  3. Copy that number after g and put a (-) before that -123456789

And, yes, Telegram supports images:

2 Likes

all i get {“ok”:true,“result”:}
can be a little more detail ??

Hi, setting up to send message to Group work but all users can send message to group. I would like that only Grafana, so the BOT, can send message to Group.
Setting permission on Group it becomes a SuperGroup and the using the s1234567 number it not work…
It’s possible send alerts to multiple Users?
Can I to set Grafana to send message to a more chat_id?

Thanks

you should

  • add your bot name (that created before) in your group (not add @BotFather in your group)
  • send a massage anything in your group,
  • open browser https://api.telegram.org/bot/getUpdates

finally you get chat id

This posts seems a bit old, but I am still replying so that it can help future users. Here is the complete steps which you need to follow in order to successfully send alert to Telegram using Grafana.

I had a hard time finding the group chat ID. To find it I navigated to https://web.telegram.org/z/ (note the ‘z’ at the end) and selected the chat group. With the group selected, you can see the chat ID in the URL. For example if your URL is https://web.telegram.org/z/#-123456789, then your chat ID is -123456789.