This guide describes how to integrate Zabbix 4.4 with Mattermost using the Zabbix Webhook feature and provides instructions on setting up a media type, a user and an action in Zabbix.
Setting up a Mattermost bot
From the Mattermost Main menu, select Integrations > Bot Accounts.
Click on the Add Bot Account button, fill in the required fields, enable permissions for post:all and post:channels and click Create Bot Account.
After the Bot Account is created, it is given an Access Token.
Note. An Access Token is only displayed at the creation step so you need to copy and save it.
You can always create a new access token with an arbitrary description. To do that, on the Bot Accounts page find your Zabbix Bot Account, click Delete > Create New Token, type a new token description in the Token Description field, and press Save.
Note. You need to copy your new access token as well, as you won’t see it again.
Add a Bot Account to your Team so that it can send messages to the team channels. To do this, in the Main Menu click Invite People, find your team in the Invite People field, and press Invite Members.
The bot can already send messages to listed public channels and user channels (direct messages). To send a message to a private channel, you need to add it as a member.
Zabbix Webhook configuration
Now you need to go to the Zabbix web interface to configure the Webhook.
Before setting up the Webhook, you need to set up the global macro {$ZABBIX.URL}, which must contain the URL to the Zabbix frontend. To do that, go Administration > General > Macros and click Add. Define the global macro in the new Macro field and your Zabbix frontend location in the Value field.
In the Administration > Media types, press Import > Choose file to import the media_mattermost.xml.
All necessary files are stored in the Zabbix repository with a link to it available on the official Zabbix integration page at www.zabbix.com/integrations/, where you can search Mattermost by name.
In Administration > Media types, open the added Mattermost Media type and set bot_token to the previously created token and mattermost_url to the frontend URL of your Mattermost installation.
You can also choose between two notification modes in the send_mode field: alarm or event.
Note. In the alarm (default) notification mode, update messages will be attached as replies to Slack message thread and recovery message from Zabbix will update the initial message. In the event notification mode, recovery and update messages from Zabbix will be posted as new messages.
Click the Update button to save the Webhook settings.
To receive notifications in Mattermost, you need to create a Zabbix user and then add Media with the Mattermost type.
To do that, go to Administration > Users and press Create user. Type ‘Mattermost alerter‘ in the Alias field and select ‘Zabbix administrators‘ in the Groups field. Then you need to set up a password.
In the Media section, you need to fill in the Send to field.
The Send to field can contain several variants of values:
- Channel name in team_name/#channel_name format;
- Channel name in team_name/@user_name format for direct messages;
- Channel identifier.
You can copy the channel identifier from the channel properties:
After adding the new user, you will need to configure actions to receive alerts in Mattermost. To do that, go to Monitoring > Problems > Update problem and check Close problem. Press Update and then Apply.
After that, you can check Mattermost messages status in Monitoring > Problems section,
as well as in the Zabbix-private section in the Mattermost frontend.
That’s all for today. You are welcome to like, comment, and subscribe.
Unfortunately it seems the “alert” mode does not actually work – it never modifies the original post. Only the even mode works, at least on Mattermost 5.39.0.
Wonderful, you made it easy for me……thanks
This isn’t working anymore since Zabbix 6.2
I’m correcting myself: I didn’t notice the template had changed, it works if you take the latest version from git.
I have error with message in Action “Mattermost notification failed: SyntaxError: invalid json (at offset 1)”
please help me