How to configure Telegram Notifications for Zabbix

In this guide, we will configure Telegram notifications for Zabbix to keep you informed about your infrastructure. You’ll learn how to set up alerts for critical events, such as when a service fails or a host goes offline, and adjust notification severity to match your needs, ensuring timely updates on your system’s health.

1. Create Telegram Bot

We will use a Telegram Bot to send notifications when a service fails or a host goes offline in Zabbix. This provides an easy, secure, and free way to receive push notifications.

  • In Telegram on your phone start a chat with @BotFather.
  • Send /start, then /newbot.
  • Username: ServerBot
  • Copy the bot token (e.g., <your_bot_token>).
  • Start a chat with your bot (@ServerBot).
  • Send a message (e.g., “Hi”).
  • Get chat ID:
    • Open: https://api.telegram.org/bot<your_bot_token>/getUpdates.
    • Find “chat”:{“id”:<your_chat_id> (e.g., <your_chat_id>).

2. Set up Telegram Media Type

First we need to download the media type “media_telegram.yaml” for our Zabbix version.
Go to Zabbix Github and choose the branch for your version of Zabbix. In this example we will use version 7.2.

Then go to templates > media > telegram and download “media_telegram.yaml” onto your computer.

In Zabbix go to Alerts > Media types and click “Import”.
Click “Choose File”, and pick the file you just downloaded, and then click “Import”.

  • In “api_parse_mode” set Value to: Markdown
  • In api_token set Value to your Telegram API Token
  • Check “Enabled”
  • Click “Update”.

3. Enable Telegram Notifications for Admin User

Go to Users > Users > Admin > Media and click “Add”

  • In “Send to” set the value to your Telegram Chat ID and click “Add”

Click “Update” to save changes.

4. Configure Conditions for Notifications

Go to Alerts > Actions > Trigger actions > “Report problems to Zabbix administrators” and click “Add”.
Set the following criteria’s:

  • Type: Trigger severity
  • Operator: is greater than or equals
  • Severity: Warning

You can also choose another severity level depending on when you want to be notified.

Click “Add” and hit “Update”.

Conclusion

You’ve now successfully configured Telegram notifications for Zabbix, ensuring you’re promptly alerted to critical events like service failures or host issues.

To test that everything works, you can simulate a failure by stopping a monitored service on your host. For example, if you’re monitoring a web server like Nginx or Apache, temporarily stop the service (e.g., on Linux, use sudo systemctl stop nginx or sudo systemctl stop apache2). If you don’t have a web server, stop any monitored service, like the Zabbix agent itself (sudo systemctl stop zabbix-agent), which will trigger an “Active checks are not available” event. Ensure the service’s trigger in Zabbix is set to a severity of Warning or higher (as configured in your action). Wait for the trigger interval (typically ~2 minutes, depending on your configuration), and when the problem appears in “Current problems” on the dashboard, check your Telegram chat for the notification. Once confirmed, restart the service (sudo systemctl start zabbix-agent) to resolve the event and verify you receive a recovery message if enabled.

With this setup, you can now confidently rely on Telegram to keep you updated on your system’s health, with the flexibility to adjust severity levels or add more triggers as needed.

Categories: Server