The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/docs/sources/alerting/configure-notifications/manage-contact-points/integrations/configure-telegram.md

3.8 KiB

canonical description keywords labels menuTitle title weight
https://grafana.com/docs/grafana/latest/alerting/configure-notifications/manage-contact-points/integrations/configure-telegram/ Configure the Telegram integration to connect alerts generated by Grafana Alerting [grafana alerting telegram integration] [{products [cloud enterprise oss]}] Telegram Configure Telegram for Alerting 300

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 obtain a Telegram bot API token and a chat ID (i.e., the ID of the Telegram chat where you want to receive the alert notifications).

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.

  1. Open the Telegram app on your device.
  2. Find the Telegram bot named BotFather.
  3. Type or press /newbot.
  4. Choose a name for the bot. It must end in bot or _bot. E.g. "my_bot".
  5. 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.

  1. In the Telegram app, open a group or start a new one.

  2. Search and add the bot to the group.

  3. Interact with the bot by sending a dummy message that starts with "/". E.g. /hola @bot_name.

    {{< figure src="/media/blog/telegram-grafana-alerting/telegram-screenshot.png" alt="A screenshot that shows a message to a Telegram bot." >}}

  4. To obtain the chat ID, send an HTTP request to the bot. Copy the below URL and replace {your_bot_api_token} with your bot API token.

    https://api.telegram.org/bot{your_bot_api_token}/getUpdates
    
  5. Paste the URL in your browser.

  6. If the request is successful, it will return a response in JSON format.

    ...
    "chat": {
            "id": -4065678900,
            "title": "Tony and Hello world bot",
            "type": "group",
    ...
    
  7. Copy the value of the “id” that appears under “chat”.

Procedure

To create your Telegram integration in Grafana Alerting, complete the following steps.

  1. Navigate to Alerts & IRM -> Alerting -> Contact points.
  2. Click + Add contact point.
  3. Enter a contact point name.
  4. From the Integration list, select Telegram.
  5. In the BOT API Token field, copy in the bot API token.
  6. In the Chat ID field, copy in the chat ID.
  7. Click Test to check that your integration works.
  8. Click Save contact point.

Next steps

To add the contact point and integration you created to your default notification policy, complete the following steps.

  1. Navigate to Alerts & IRM -> Alerting -> Notification policies.
  2. In the Default policy, click the ellipsis icon (…) and then Edit.
  3. Change the default policy to the contact point you created.
  4. Click Update default policy.

{{}} If you have more than one contact point, add a new child notification policy rather than edit the default one, so you can route specific alerts to Telegram. {{}}