Grafana alert notifications on Telegram & Discord

Document history

DateChanges
23. December 2020Published

Important notes & disclaimer

This guide is provided without any warrenty/guarantee (“as is”). Feel free to let us know your feedback! We are happy to apply healthy critique to this guide!

Overview

We’ll go through following topics to get notifications on Telegram and/or Discord

  • Create a Telegram Bot
  • Create a Discord server & channel
  • Add notification channels to the grafana

Create a Telegram-Bot

First we need to log in to Telegram. If you already have a telegram-account, go here and log in, if not then go here and follow the steps to create a new telegram-account. You can use a web browser or telegram app to log in. In this guide we’re going to utilize web browser

Once you have successful logged in to telegram, type in search box <BotFather> and click on it. <BotFather> telegram bot will assist you to creating your bot

search BotFather

Next click on <START> to begin to communicate with <BotFather>

start BotFather

Now it’s ready to create a new bot

botfather

Type /newbot to create a new bot

create new bot

Next <BotFather> will ask you to choose a name for your new bot. In this case <stereum_test> is chosen as bot name

choose bot name

The <BotFather> will also ask you to choose a username for your bot. The username must in end `bot` also must unique. In this guide <stereum_test_bot> is chosen as username. After that you will get your BOT HTTP API token and it will be used to control your telegram bot. Keep it safely!

username & HTTP API token

In this case BOT HTTP API token: 1457063729:AAHvldeG-JdmdTlyzssY8owWPTlMOQzaf9I and it will be used in the last step to set up notification channel on the grafana

Open your favorite web browser and visit https://api.telegram.org/bot<your-HTTP-API-token>/getUpdates, instead <your-HTTP-API-token> put your HTTP API token. At the moment there is nothing to show on the web browser, since a bot is just created. However leave it open to get Chat-ID on that window in the next step. It should look something like this

api telegram

Next we’re going to create a new group on the telegram which will be used to receive the alerts from Grafana. To do that click on top left corner and select <New group>

create new group

Type your bot’s username (in this case stereum_test_bot) and select your bot to add into the group, then click on <NEXT>

add bot user into the group

Next choose your group name (in this case <stereum_test_group>) then click on <CREATE GROUP>

create group

We’ve just created a new group on the telegram. Click on the top <your-group-name> to get a list of your group members.

members of the group

Here you can see that newly created bot is added to this group. Click on bot (in this case: stereum_test)

list of group members

To get bot’s Chat-ID, bot have to be part of some activity. Here we’re going to use <Add to group> to add the bot into the group again

add to group

Next choose your group which is created previously

choose group

Go back to the web browser, which we’ve already opened previously and press <F5> then you’ll get bot’s <Chat-ID> as shown below

Chat-ID

Latest activities will be written at the bottom of the page. Therefore you’ll find your bot’s <Chat-ID> bottom-most, since bot is just invited to the group.

Bot <Chat-ID> should begin with a minus <-> sign. In this case Chat-ID:-481124770 and it will be used in the last step to set up notification channel on the grafana

Completed! Congratulation! Now your telegram-bot is ready to be configured as notification channel on the grafana

Create Discord server & channel

First we need to log in to Discord. If you already have a discord-account, go here and log in, if not then go here and follow the steps to create a new Discord-account. You can use a web browser or discord app to log in. In this guide we’re going to utilize web browser

Once you have successful logged in to discord, click on <+> sign on the left panel to add a new server on discord

add a server

Then select <Create My Own> option as shown below

create my own server

Next choose & type your server name. In this case <stereum-test-server> is chosen as server name. Then click on <Create>

You’ll see the newly created server on the left panel and Welcome to <your-server-name> message!

newly created server

Let’s create a new text channel on your discord server which will be used to receive alert notifications from grafana. To do that click on <+> sign as shown below

Put your channel name in <CHANNEL NAME> bar and click on <Create Channel>. In this case <stereum-test-channel> is chosen as a channel name

create new text channel

Once your server and text channel are successful created then right click on the server and select Server Settings -> Integrations where we’re going to create discord Webhook.

go to the server settings

Click on <Create Webhook>

create webhook

On the next window

  1. choose a name for your webhook. In this case <stereum-test-webhook> is chosen as name
  2. select your previously created text channel in the dropdown menu. In this case <stereum-test-channel> is chosen as channel
  3. click on <Copy Webhook URL>. This URL will be used in the next step to set up notification channel on the grafana
copy webhook URL

Done! Congratulation! Now your discord server and channel is ready to be configured as notification channel on the grafana.

Add notification channel to the Grafana

First we need to log in to Grafana. if you already familiar with grafana visit here, put your username and password to log in. If not visit here and put <admin> as username as well as password, then you’ll be asked to provide new password for grafana. Give your password and you are in!

Once you have successful logged in to grafana, click on <Alerting> (Bell icon on the left panel) and select <Notification channels> as shown below

notification channels

Then click on <Add channel> to add new notification channel to the grafana

Telegram

The following steps needed to be configured on the grafana to get alert notifications on the telegram

telegram notification channel
  1. Choose a name for the notification channel. Here <telegram-stereum> is chosen as name of the notification channel
  2. Choose <Telegram> in the dropdown menu
  3. Provide your telegram BOT HTTP API token which is already created above
  4. Put your bot’s <Chat-ID> which is also created previously
  5. Tick <Default> option to receive notifications from alerts which are configured on the grafana
  6. Tick <Include image> option to get notifications with graphical illustration of your grafana panels. Grafana image renderer is required to get graphical sample and it’s already installed as well as set up on the ethereum2-docker-compose
  7. Click on <Test>. All goes well, then you will get test message as shown below
  8. Click on <Save>!
telegram test notification

Congratulation! The Telegram notification channel is configured and saved on the grafana and you’ll get notifications from grafana on your telegram

Discord notifications

The following steps needed to be configured on the grafana to get alert notifications on the discord

discord notification channel
  1. Choose a name for the notification channel. Here <discord-stereum> is chosen as name of the notification channel
  2. Choose <Discord> in the dropdown menu
  3. Provide your discord Webhook which is already created above
  4. Tick <Default> option to receive notifications from the alerts which are configured on the grafana
  5. Tick <Include image> option to get notifications with graphical illustration of your grafana panels. Grafana image renderer is required to get graphical sample and it’s already installed as well as set up on the ethereum2-docker-compose
  6. Click on <Test>. All goes well, then you will get test message as shown below
  7. Click on <Save>!
discord test notification

Great, done! The Discord notification channel is configured and saved on the grafana and you’ll get notifications from grafana on your discord

Thanks for reading & Enjoy Notifications!

Grafana alert notifications on Telegram & Discord
Scroll to top