Grafana Alerting with Telegram

6 August, 2024

Joshua Hartmann
Joshua Hartmann
Systems Engineer

Joshua hat im Sommer 2023 seine Ausbildung zum Fachinformatiker für Systemintegration bei den NETWAYS Web Services erfolgreich abgeschlossen. Heute ist er ein wichtiger Teil des Teams, das sich mit großer Hingabe um die Kundenbetreuung und die kontinuierliche Weiterentwicklung der SaaS-Apps kümmert. Neben seinem musikalischen Talent am Klavier hat Joshua eine Leidenschaft für Wintersport und findet auch Freude im Gaming. Doch am allerliebsten verbringt er seine Zeit mit seiner besseren Hälfte, denn sie ist für ihn das größte Glück.

by | Aug 6, 2024

Monitoring is a crucial component for many systems and indispensable for maintaining a good system status. Especially for critical systems, it is important to be informed about potential problems in a timely and efficient manner. Notifications about the status of your systems can be sent via Grafana Alerting, for example.

You may have noticed that we recently launched a Managed Prometheus App that combines Prometheus and Grafana. Prometheus is the leading open source monitoring solution that allows you to collect, aggregate, store and query metrics from various IT systems. Grafana complements this by providing intuitive data visualization through well-designed dashboards. However, to receive notifications from your systems, you need Grafana Alerting. Grafana Alerting supports notifications via email, SMS and many other channels.

In this guide, we will show you a simple and effective way to receive notifications from Grafana directly on your device by configuring Grafana Alerting with Telegram. The setup is quick and can be completed in just a few minutes.

Would you like to get started right away and try out our Managed Prometheus app? Then click here and test it free of charge for 30 days.

How to set up Grafana Alerting with Telegram

Prerequisites

  • Grafana (preferably the Managed Prometheus app)
  • Telegram with your own account

Step 1: Create a Telegram bot and get the bot API token

First, make sure you have a Telegram account. Next, you will need two important pieces of information: the bot API token and your chat ID (the ID of the Telegram chat in which you want to receive notifications). This allows you to assign the bot to your chats and perform various actions.

Follow these steps to set up the Telegram bot:

  1. Open Telegram on your device.
  2. Search for the bot named BotFather.
  3. Enter /help in the chat to display all possible commands.
  4. To get the Bot API token, create your own bot by entering /newbot.
  5. Follow the instructions (choose a name for the bot that ends with “bot” or “_bot”).
  6. Copy your HTTP API token.
Screenshot of the dialog with Telegram's 'BotFather' for the creation of the bot for Grafana Alerting with Telegram.
The BotFather guides you through the creation of your bot for Grafana Alerting with Telegram.

Step 2: Retrieve the Telegram chat ID

After you have received the bot API token, add your bot to a group chat to receive the chat ID.

  1. Create a new group in the Telegram app.
  2. Search for the bot you have created and add it to the group.
  3. Interact with the bot by sending messages that begin with “/“.
  4. Send an HTTP request to the bot to retrieve the chat ID. Copy the following URL and replace {dein_bot_api_token} with your bot API token:
    https://api.telegram.org/bot{dein_bot_api_token}/getUpdates
  5. Call upthe URL in your browser.
  6. If the request is successful, you will receive a response in JSON format.
  7. Copy the value under “chat” at “id”.

Example task:

{"ok":true,"result":[{"update_id":301357744,"my_chat_member":{"chat":{"id":-4227950682,"title":...

Step 3: Configure Grafana alerting with Telegram

The last step is to create a contact point for Telegram in Grafana Alerting and link it to a notification channel.

Create the contact point

Add a new contact point for Telegram in Grafana by following these steps:

  1. Navigate in the sidebar to Alerting > Contact points.
  2. Click on + Add contact point.
  3. Name the contact.
  4. Select Telegram under Integration.
  5. Enter your Telegram login details: Bot API tokenand chat ID.
  6. Click on Test to check whether the integration works. If this is not the case, make sure that your login information has been copied and pasted correctly.
  7. Click on Save contact point.
You can add your Telegram bot via the ‘Contact points’ menu of Grafana to configure Grafana Alerting with Telegram.

If the test was successful, it should look something like this:

The test alarm from Grafana looks similar to the message above.

That’s it already! You have successfully activated Grafana Alerting with Telegram. Have fun with Grafana Alerting!

If you have any further questions about our new NETWAYS Managed Prometheus App or the setup with Grafana Alerting, please do not hesitate to contact us or get in touch with our MyEngineer®.

Our portfolio

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

How did you like our article?