Use Telegram for Alerts
This guide explains how to configure OpenObserve alerts to send notifications directly to Telegram. You will create a template, configure an alert destination, and attach it to an alert rule.
Configure OpenObserve alerts
Prerequisites
- A Telegram account
- Telegram bot token: Create a bot in Telegram using BotFather. BotFather provides the token.
- Telegram chat ID: Start a chat with your bot, send a message, and run
getUpdates
with your bot token to retrieve thechat.id
.
Verify the bot token and chat ID with the following commands:
Get updates
Get bot details
Send a test message
If the message appears in Telegram, your setup is correct.Step 1: Create Template
- Go to Management > Templates > Add Template.
- Enter a name, for example
Telegram_alert
. - Select Web Hook.
- In the Body, add the following JSON. Replace
with your chat ID. - Save the template.
Step 2: Create Alert Destination
- Go to Management > Alert Destinations > Add Destination.
- Enter a name, for example
Telegram_alert
. - Select the template you created earlier (Telegram_alert).
- Set URL to: https://api.telegram.org/bot
/sendMessage - Set Method to POST.
- Add the header: Content-Type = application/json
- Save the destination.
Step 3: Create Alert
- Go to Alerts > Add Alert.
-
Configure the alert:
- Name: any name
- Stream Type: logs
- Stream Name: select your stream. For example, default.
- Alert Type: Scheduled
- Condition: for example service_name = ingress-nginx
- Threshold: >= 1 time
- Period: 1 minute
- Frequency: 1 minute
- Destination: select
Telegram_alert
- In Row Template, define the row format, for example:
Alert was active at {_timestamp}
-
Save the alert.
Step 4: Verify alert delivery
After you save the alert, wait until the condition is met.
If configured correctly, you will receive a message in Telegram that looks similar to the following:
Troubleshooting
Issue: No message received in Telegram
Solution: Verify that the template body includes a valid chat_id
. Without chat_id
, Telegram cannot deliver the message.
Example of a valid body:
{ "chat_id": "8237**", "text": "{alert_name} is active \nDetails:\n{rows}" }