Integrate Telegram as a media type for Zabbix alerts

Posted By : Niharika Bariar | 29-Aug-2022

Through this blog, we are going to let you know about adding telegram as a media type to receive alerts in Zabbix.(Zabbix Version: zabbix-release_6.0-1)


Part 1: Telegram Webhook Setup


1. Register a new bot: send /newbot to @BotFather. As it sends a welcome message it asks to provide a bot name for your alert. For example: ZabbixAlerts. Next, it asks for the username for the bot. (Note: it should end in bot, like ZabbixProdAlertsBot). Then it gives a success message with a link like (t.me/user_name) and the token number, which we will be using to configure the telegram in Zabbix dashboard


2. Like there is a "To" field in email, you will need your own telegram id to configure and allow Zabbix to send messages to you.

Search on telegram users for the bot "@myidbot" and send :

  • /start
  • /getid


Now the user needs to send /start in the username bot you created from step 1. Otherwise, the telegram bot won't be able to send messages to the user.


After this step, we will create a group bot, where we will be getting our notifications/alerts. Give it a meaningful name, like so: My Zabbix Alerts


3. To initialize group notifications, you need to obtain the group ID of the group the bot should send messages to. For that, add @myidbot and @usernamebot in the group created in the previous step. In this group, Send

  • "/getgroupid@myidbot" message, which will give this group's id, like so -123456789. If u don't get this id, try opening web.telgram.org in your desired browser, which will show the id in the address bar. We need to keep this handy and safe.
  • send "/start@your_user_name_bot" in this group, which will allow this telegram group bot to receive messages from Zabbix.


Part 2: Zabbix configuration


In the Navigation menu select Administration--> Media Types

 

  1. copy and paste the telegram token in the "Token" field.
  2. copy and paste the group id in the "To" field, leave the defaults as is and save the configuration.
  3. navigate back to the media type page, scroll to the right and press the "Test" button to check the configuration. If it gives "Media type test successful" message, we are good to go ahead.
  4. In case forgotten to send /start to the bot, it will throw an error, like "chat not found".


Now we are left with adding the webhook to the user!


For that head over to the Users section in the Zabbix dashboard,

  1. Choose the user who will receive the alert, and switch to the media tab.
  2. Click on add, then in the popup, select telegram in the dropdown, and save it. And that is it!


We will start to have alerts on our Telegram !!

 

About Author

Author Image
Niharika Bariar

She works in dealing with Devops procedures in Blockchain, using Docker, Jenkins on Nodejs and React Applications making them high available and robust.

Request for Proposal

Name is required

Comment is required

Sending message..