ℹ️ Disclaimer: This was developed on Zabbix 4.0, but I see no reason it shouldn't work on newer versions as well. ℹ️
This page will show you how to setup and configure the zabbix-teams.sh
script to be implemented so that you will receive Zabbix problem alerts in the desired Microsoft Teams channel of your choosing.
- If a copy of
zabbix-teams.sh
isn't yet located on the Zabbix server being utilized, please perform the following:cd /usr/lib/zabbix/alertscrips
curl -O https://raw.githubusercontent.com/jaredbrogan/Zabbix-Teams/main/zabbix-teams.sh
chown root:zabbix zabbix-teams.sh ; chmod a+x zabbix-teams.sh
- Once the script has been downloaded and permissions have been corrected, you will now need to perform the frontend setup:
- On the Zabbix Frontend, navigate to Administration → Media Types
- Click Create media type on the top right of the page
- Enter the following:
- Name: Microsoft Teams
- Type: Script
- Script name: zabbix-teams.sh
- Script parameters:
- {ALERT.SENDTO}
- {ALERT.SUBJECT}
- {ALERT.MESSAGE}
- Leave everything else as default.
- Be sure the Enabled checkbox remains checked
- Should look like this:
- The next step is to create a new macro to be used in our new alerts. Please perform the following:
- On the Zabbix Frontend, navigate to Administration → Macros
- Click the small Add button
- In the Macro column, enter
{$ZABBIX_URL}
- In the Value column, enter your specific Zabbix web URL
- Click the Update button to apply this change.
- The new macro should look something like this:
Now that we have the new media type created, we can move forward with the next section! 🙂
With the new media type created, our next step will be to determine where we'll be sending our alerts to.
Assuming you have the ability to either create a new channel in the desired team of your choice --
Please perform the following:
- Navigate to the channel where alerts will be sent to.
- Click on the ellipsis (…) located to the right of the channel's name
- Select the Connectors option
- Locate the Incoming Webhook item and select Configure
- Give a name for this incoming webhook, maybe "Zabbix"
- Now upload an image for it
- Feel free to use the image to the right ⟶
- Now select Create
- Now that the incoming webhook has been created, you should now see a generated webhook URL that can be referenced specifically for this channel
Now would be a good time to copy this URL for the next section 😁
With the Teams setup completed, we will finish our setup on the Zabbix Frontend section.
First, we will create a new user to be used specifically for this functionality.
Please perform the following:
- On the Zabbix Frontend, navigate to Administration → Users
- Click Create media type on the top right of the page
- Enter the following:
- Alias: MS Teams - [Channel Name]
- Name: [MS Team Name]
- Surname: [Channel Name]
- Groups: 'No access to the frontend' & 'Microsoft Teams'
- Password: zabbix
- Note: This account will not actually be able to login.
- Click the Media tab above
- Perform the following:
- Click the tiny Add button underneath Type
- Select Microsoft Teams from the drop-down menu
- Copy/paste the previously generated incoming webhook URL into the Send to field
- Leave When active and Use if severity as default
- Be sure the Enabled checkbox remains checked
- Click the Add button
- Click the Add button again
- Click the Permissions tab above
- Select Zabbix Super Admin from the User type drop-down menu
With the user now created, we can move on to the final step! 😃
Now for the final step, we will create a new action in Zabbix.
Please perform the following:
- On the Zabbix Frontend, navigate to Configuration → Actions
- Click Create action on the top right of the page
- Enter the following:
- Name: [HOST GROUP] - Teams Channel
- Conditions
- Create the following conditions:
- Problem is not suppressed
- Trigger severity is greater than or equals Average
- Host group equals [group(s) that apply]
- Create the following conditions:
- Leave everything else on this tab as default
- Be sure the Enabled checkbox remains checked
- Click the Operations tab above
- Enter the following:
- Default subject: [HOST GROUP]: {TRIGGER.STATUS} - {TRIGGER.NAME}
- Default message:
Solution: <i>__[HOST GROUP]__</i><br> Host: __{HOST.HOST}__ <br> <ul> <li> Trigger: {TRIGGER.NAME} </li> <li> Trigger status: {TRIGGER.STATUS} </li> <li> Trigger severity: {TRIGGER.SEVERITY} </li> <li> Trigger URL: <a href={TRIGGER.URL}>{TRIGGER.URL}</a> </li> <li> Trigger Description: {TRIGGER.DESCRIPTION} </li> <li> Item value: {ITEM.LASTVALUE} </li> </ul> Original event ID: {EVENT.ID} <br> Action: <i>{ACTION.NAME}</i> <br> PROB_URL: {$ZABBIX_URL}/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID} <br> ACK_URL: {$ZABBIX_URL}/zabbix/zabbix.php?action=acknowledge.edit&eventids%5B0%5D={EVENT.ID}&backurl=tr_events.php%3Ftriggerid%3D{TRIGGER.ID}%26eventid%3D{EVENT.ID}
- Leave Pause operations for suppressed problems checked
- Click New located under the Operations area below
- Click Add located within the Send to Users section
- Select the previously created user
- Select Microsoft Teams from the drop-down menu for the Send only to field
- Leave Default message checked
- Under Conditions, click New
- There should be a default condition labeled as Event acknowledged equals Not Ack
- Click the small Add button
- Click the other small Add button
- Click the Recovery operations tab above
- Enter the following:
- Default subject: [HOST GROUP]: {TRIGGER.STATUS} - {TRIGGER.NAME}
- Default message:
Solution: <i>__[HOST GROUP]__</i><br> Host: __{HOST.HOST}__ <br> <ul> <li> Trigger: {TRIGGER.NAME} </li> <li> Trigger status: {TRIGGER.STATUS} </li> <li> Trigger severity: {TRIGGER.SEVERITY} </li> <li> Trigger URL: <a href={TRIGGER.URL}>{TRIGGER.URL}</a> </li> <li> Trigger Description: {TRIGGER.DESCRIPTION} </li> <li> Item value: {ITEM.LASTVALUE} </li> </ul> Original event ID: {EVENT.ID} <br> Action: <i>{ACTION.NAME}</i> <br> PROB_URL: {$ZABBIX_URL}/zabbix/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID} <br> ACK_URL: {$ZABBIX_URL}/zabbix/zabbix.php?action=acknowledge.edit&eventids%5B0%5D={EVENT.ID}&backurl=tr_events.php%3Ftriggerid%3D{TRIGGER.ID}%26eventid%3D{EVENT.ID}
- Click New located under the Operations details area below
- Perform the following:
- Under Operation type, select Notify all involved
- Leave Default message checked
- Click the small Add button
- Perform the following:
- Enter the following:
- Click the Update operations tab above
- Enter the following:
- Default subject: [HOST GROUP]: Acknowledged - {TRIGGER.NAME}
- Default message:
The alarm for __{TRIGGER.NAME}__ has been acknowledged. <ul> <li> User: {USER.FULLNAME} </li> <li> Host: {HOST.HOST} </li> <li> Time: {ACK.DATE} at {ACK.TIME} </li> <li> Message: {ACK.MESSAGE} </li> </ul> Current problem status is __{EVENT.STATUS}__.
- Click New located under the Operations area below
- Perform the following:
- Under Operation type, select Notify all involved
- Under Default media type, select Microsoft Teams
- Leave Default message checked
- Click the small Add button
- Perform the following:
- Now click the BIG Add button
- Once created, it should resemble this:
- Enter the following:
Please enjoy the additional notifications! 😎👍