Configure Telegram for Alerting
Use the Grafana Alerting - Telegram integration to send Telegram notifications when your alerts are firing.
Before you begin
Telegram limitation
Telegram messages are limited to 4096 UTF-8 characters. If you use a parse_mode
other than None
, truncation may result in an invalid message, causing the notification to fail.
For longer messages, we recommend using an alternative contact method.
Telegram bot API token and chat ID
To integrate Grafana with Telegram, you need to get a Telegram bot API token and a chat ID (the ID of the Telegram chat where you want to receive the alert notifications). To complete the integration, use the browser version of Telegram.
Set up your Telegram bot
Create a Telegram bot. You can associate this bot to your chats and perform different actions with it, such as receiving alerts from Grafana.
To set up the bot, complete the following steps.
- Open the Telegram app on your device.
- Find the Telegram bot named BotFather.
- Type or press
/newbot
. - Choose a name for the bot. It must end in bot or _bot. E.g. “my_bot”.
- Copy the API token.
Chat ID
Add the bot to a group chat by following the steps below. Once the bot is added to the chat, you will be able to route your alert notifications to that group.
In the Telegram app, open a group or start a new one.
Search and add the bot to the group.
Copy the chat ID from the URL in your browser’s address bar. It should look like this:
https://web.telegram.org/a/#-4266674385
.The chat ID is the sequence of numbers that follows the
#
symbol. For example:-4266674385
.
Procedure
To create your Telegram integration in Grafana Alerting, complete the following steps.
Navigate to Alerts & IRM -> Alerting -> Contact points.
Click + Add contact point.
Enter a contact point name.
From the Integration list, select Telegram.
In the BOT API Token field, copy in the bot API token.
In the Chat ID field, copy in the chat ID.
Click Test to check that your integration works.
** For Grafana Alertmanager only.**
Click Save contact point.
Next steps
The Telegram contact point is ready to receive alert notifications.
To add this contact point to your alert, complete the following steps.
- In Grafana, navigate to Alerting > Alert rules.
- Edit or create a new alert rule.
- Scroll down to the Configure labels and notifications section.
- Under Notifications click Select contact point.
- From the drop-down menu, select the previously created contact point.
- Click Save rule and exit.