Zabbix Integration Guide
Zabbix is a popular open source service for monitoring IT components, like servers, networks, virtual machines and cloud services.
What can Zenduty do for Zabbix users?
With Zabbix's Integration, Zenduty sends new Zabbix alerts to the right team and notifies them based on on-call schedules via email, text messages(SMS), phone calls(Voice), Slack, Microsoft Teams and iOS & Android push notifications, and escalates alerts until the alert is acknowledged or closed. Zenduty provides your NOC, SRE and application engineers with detailed context around the Zabbix alert along with playbooks and a complete incident command framework to triage, remediate and resolve incidents with speed.
Whenever Zabbix triggers an alert based on a predefined condition, Zenduty will create an incident. When that condition goes back to normal levels, Zenduty will auto-resolve the incident.
You can also use Alert Rules to custom route specific Zabbix alerts to specific users, teams or escalation policies, write suppression rules, auto add notes, responders and incident tasks.
To integrate Zabbix with Zenduty, complete the following steps:
In Zenduty:
-
To add a new Zabbix integration, go to Teams on Zenduty and click on the team you want to add the integration to.
-
Next, go to Services and click on the relevant Service.
-
Go to Integrations and then Add New Integration. Give it a name and select the application Zabbix from the dropdown menu.
-
Go to Configure under your integrations and copy the API KEY(for below Zabbix 5.0.6 version) and API URL(for Zabbix 5.0.6 and above) generated.
Select your Zabbix version
Zabbix Setup for versions below v5.0.6
For Zabbix v5.0.6 and above
In Zabbix:
Create the Zenduty media type:
-
In Zabbix Go to the Administration tab.
-
Under Administration, go to the Media types page and click the Create Media Type button.
-
On the following Media Type configuration page, enter Zenduty for Name, Select Webhook as Type and Mention below key value pairs in Parameters. Below Parameters are mandatory to get alert in Zenduty. Additional key value pairs can be included here based on your requirement.
Name | Value |
---|---|
problem | {TRIGGER.NAME} |
problem_started_at | {EVENT.TIME} on {EVENT.DATE} |
problem_name | {TRIGGER.NAME} |
host | {HOST.NAME} |
severity | {TRIGGER.SEVERITY} |
original_problem_id | {TRIGGER.ID} |
event_status | {EVENT.STATUS} |
host_ip | {HOST.IP1} |
message | {ALERT.MESSAGE} |
trigger_description | {TRIGGER.DESCRIPTION} |
trigger_expression | {TRIGGER.EXPRESSION} |
trigger_status | {TRIGGER.STATUS} |
trigger_url | {TRIGGER.URL} |
trigger_value | {TRIGGER.VALUE} |
url | <URL That you copied from Step 4 above> |
-
Copy the script below and paste it in the Script section.
Important - For Zabbix versions below v6.2 use the script below
try { var params = JSON.parse(value), req = new CurlHttpRequest(), response; if (params.HTTPProxy) { req.setProxy(params.HTTPProxy); } Zabbix.Log(1, params.url); req.AddHeader('Content-Type: application/json'); Zabbix.Log(4, '[ Zenduty webhook ] Webhook request with value=' + value); response = req.Post(params.url, JSON.stringify(params)); Zabbix.Log(4, '[ Zenduty webhook ] Responded with code: ' + req.Status() + '. Response: ' + response); try { response = JSON.parse(response); } catch (error) { if (req.Status() < 200 || req.Status() >= 300) { throw 'Request failed with status code ' + req.Status(); } else { throw 'Request success, but response parsing failed.'; } } if (req.Status() != 200 && req.Status() != 201 ) { throw response.error; } return 'OK'; } catch (error) { Zabbix.Log(3, '[ Zenduty webhook ] Sending failed. Error: ' + error); throw 'Failed with error: ' + error; }
Important - For Zabbix versions v6.2 and above use the script below]
try { var params = JSON.parse(value), req = new HttpRequest(), response; if (params.HTTPProxy) { req.setProxy(params.HTTPProxy); } Zabbix.Log(1, params.url); req.addHeader('Content-Type: application/json'); Zabbix.Log(4, '[ Zenduty webhook ] Webhook request with value=' + value); response = req.post(params.url, JSON.stringify(params)); Zabbix.Log(4, '[ Zenduty webhook ] Responded with code: ' + req.getStatus() + '. Response: ' + response); try { response = JSON.parse(response); } catch (error) { if (req.getStatus() < 200 || req.getStatus() >= 300) { throw 'Request failed with status code ' + req.getStatus(); } else { throw 'Request success, but response parsing failed.'; } } if (req.getStatus() != 200 && req.getStatus() != 201 ) { throw response.error; } return 'OK'; } catch (error) { Zabbix.Log(3, '[ Zenduty webhook ] Sending failed. Error: ' + error); throw 'Failed with error: ' + error; }
-
Give Timeout as 30s and write a description for Zenduty Media type.
-
In Media Type, Go to Message Template and create templates for Respective message type. Like Problem, Problem recovery etc. Minimum configure for 3 types of messages (Problem, Problem Recovery and Problem Update) as shown below.
-
In Option Tab you can configure concurrent sessions based on your use. Give 3 as attempts and 10s as Attempt interval.
Create the Zenduty user and user group for alerting:
-
Go to the Administration tab.
-
Under Administration, go to the Users Groups page and click the Create user group button.
-
Enter a name in the Group name field that identifies it as part of the integration. In this guide, we use Zenduty Service.
-
Grant read permissions on Host Groups to the user group, to choose which hosts will produce Zenduty notifications when they have alerts, as follows:
-
Click to the Permissions tab.
-
Select the Read permission level and click on the Select button.
-
Select which Host Groups you would like the Zenduty to have read access to for monitoring, then click the Select button. In this example, we grant the Zenduty group read access to the Linux servers and Zabbix servers.
-
-
Click on Add to save your new user group.
-
Click on the Users tab (under Administration) and click the Create User button.
-
Fill in the details of this new user, and call it Zenduty User. The default settings for Zenduty User should suffice as this user will not be logging into Zabbix.
-
Click the Select button next to Groups.
-
Click on the Media tab and, inside of the Media box, click the Add button.
-
Select the media type that you have created earlier, and paste the URL that you have copied above in the Send to section.
Create the alert action:
-
Go to the Configuration tab.
-
Under Configuration, go to the Trigger Action in the Action tab, and click on Create Action.
-
Give the action a name such as Zenduty Notifications.
-
Go to the Operations tab, and configure as follows:
-
Under Send to user groups and Send to users, add the User and User group that has been created for Zenduty.
-
Select the Zenduty Media type that you have created in the earlier step.
-
-
Repeat the above step for Recovery and Update Operations.
-
Click the Add button at the bottom of any of the action tabs to save your action.
-
Zabbix is now integrated with Zenduty.
Zabbix Setup for versions below v5.0.6
In Zabbix:
-
Clone this Repository
git clone https://github.com/Zenduty/zabbix-zenduty-script.git
-
Copy the Script file(zabbix_zenduty_integration.sh) and paste it into Zabbix server's AlertScriptsPath. You can see your AlertScriptsPath path from Zabbix server configuration file. Give executable permission to this file for the Zabbix user.
chmod 555 zabbix_zenduty_integration.sh
Create the Zenduty media type:
-
In Zabbix Go to the Administration tab.
-
Under Administration, go to the Media types page and click the Create Media Type button.
-
On the following Media Type configuration page, enter Zenduty for Name, Select script in type and write the name of the file which you have pasted in AlertScriptPath.
-
Click the Add link in the Script parameters box two times to create two configurable parameters for the script, and enter the following template values for the two parameters in exactly the following order:
{ALERT.SENDTO} {ALERT.MESSAGE}
-
Click the Add button at the bottom to save and create the Zenduty media type.
Create the Zenduty user and user group for alerting:
-
Go to the Administration tab.
-
Under Administration, go to the Users Groups page and click the Create user group button.
-
Enter a name in the Group name field that identifies it as part of the integration. In this guide, we use Zenduty Service.
-
Grant read permissions on Host Groups to the user group, to choose which hosts will produce Zenduty notifications when they have alerts, as follows:
-
Click to the Permissions tab.
-
Select the Read permission level and click on the Select button.
-
Select which Host Groups you would like the Zenduty to have read access to for monitoring, then click the Select button. In this example, we grant the Zenduty group read access to the Linux servers and Zabbix servers.
-
-
Click on Add to save your new user group.
-
Click on the Users tab (under Administration) and click the Create User button.
-
Fill in the details of this new user, and call it Zenduty User. The default settings for Zenduty User should suffice as this user will not be logging into Zabbix.
-
Click the Select button next to Groups.
-
Click on the Media tab and, inside of the Media box, click the Add button.
-
Select the type that you have created in step 7, paste the key that you have copied from Zenduty in Send to.
Create the alert action:
-
Go to the Configuration tab.
-
Under Configuration, go to the Actions page, and click on Create Action.
-
Give the action a Name such as Zenduty Notifications.
-
Go to the Operations tab, and configure as follows:
-
Delete the contents of the Default message field, and insert the following:
{"problem":"{TRIGGER.NAME}", "problem_started_at": "{EVENT.TIME} on {EVENT.DATE}", "problem_name": "{TRIGGER.NAME}", "host": "{HOST.NAME}", "severity": "{TRIGGER.SEVERITY}", "original_problem_id": "{TRIGGER.ID}", "event_status":"{EVENT.STATUS}", "host_ip":"{HOST.IP1}", "trigger_description":"{TRIGGER.DESCRIPTION}", "trigger_expression":"{TRIGGER.EXPRESSION}", "trigger_status":"{TRIGGER.STATUS}", "trigger_url":"{TRIGGER.URL}", "trigger_value":"{TRIGGER.VALUE}"}
-
Under Operations, click New, and in the resulting operation details configuration, under Send to User groups, click Add. In the pop-up window, check the box by the Zenduty service user group, click Select, and then click Add at the bottom of the Operations section.
-
-
Go to the Recovery Operations tab and configure the rest of the options in the same way as in steps 1-2 in the Operations configuration (see above). For instance, the content of the Recovery message should be the same as the Default message.
-
Go to the Acknowledgment Operations tab and configure the rest of the options in the same way as with the Operations and Recovery operations, above.
-
Click the Add button at the bottom of any of the action tabs to save your action.
-
Zabbix is now be integrated with Zenduty.