Skip to content

Zabbix

Zabbix’s webhook media type runs actual JavaScript to build the outbound payload — the most flexible option of any integration in this section, since it’s a real script rather than placeholder substitution.

See API Overview for authentication and finding your Account ID/Team ID.

  1. In Zabbix, go to Administration → Media types and create a new Webhook media type (or start from Zabbix’s built-in Webhook template and modify it).
  2. Add parameters for the values your script needs: alert_subject, alert_message, alert_severity, alert_status, account_id, team_id, api_key — Zabbix populates these from its own macros (e.g. {ALERT.SUBJECT}, {ALERT.MESSAGE}, {TRIGGER.SEVERITY}, {EVENT.VALUE}) when the media type is triggered, except account_id and api_key, which you set as fixed parameter values (your OpsFusion account is the same for every alert).
  3. In the Script field, write the JavaScript below to build the request body and call OpsFusion’s API.
  4. Create a User with this media type configured, and an Action that triggers it on the trigger events you want paged.
try {
var params = JSON.parse(value);
var severityMap = {
'Disaster': 1, 'High': 1,
'Average': 2, 'Warning': 2,
'Information': 3, 'Not classified': 3
};
var payload = {
teamId: parseInt(params.team_id),
title: params.alert_subject,
description: params.alert_message,
severity: severityMap[params.alert_severity] || 3,
status: params.alert_status === '1' ? 1 : 3,
labels: { source: 'zabbix' }
};
var req = new HttpRequest();
req.addHeader('Content-Type: application/json');
req.addHeader('Authorization: ' + params.api_key);
var resp = req.post(
'https://api.opsfusion.cloud/v1/account/' + params.account_id + '/push/alert',
JSON.stringify(payload)
);
if (req.getStatus() >= 300) {
throw 'OpsFusion API returned ' + req.getStatus() + ': ' + resp;
}
return 'OK';
} catch (error) {
Zabbix.log(4, '[OpsFusion Webhook] ' + error);
throw 'OpsFusion webhook failed: ' + error;
}

account_id is fixed — it’s your OpsFusion account, set once as a media type parameter default rather than pulled from a Zabbix macro. team_id, by contrast, is worth keeping as a per-trigger/per-host-group parameter, so a single media type can route different Zabbix host groups to different OpsFusion teams.

OpsFusion fieldZabbix source
teamIdPassed in as a macro/parameter, mapped per host group or trigger
title{ALERT.SUBJECT}
description{ALERT.MESSAGE}
severityMapped from {TRIGGER.SEVERITY} in the script’s severityMap
statusMapped from {EVENT.VALUE} (1 = problem, 0 = resolved)
labelsFreeform — add any other Zabbix macros you want as context
  • Script errors visible in Zabbix logs: check Reports → Action log for the specific error thrown — the script above logs failures via Zabbix.log and re-throws so they’re visible there.
  • Wrong severity mapping: Zabbix’s severity names are configurable per-installation; confirm severityMap in the script matches your instance’s actual severity labels, not just the defaults.
  • HttpRequest unavailable: Zabbix’s webhook JavaScript sandbox (Duktape) supports HttpRequest natively — if you get a reference error, confirm you’re running a Zabbix version recent enough to support webhook media types (6.0+).

For integration support: