amonit

← Docs

Connect Zabbix to Amonit

Amonit team · Updated

Short answer: create a Zabbix media type of type Webhook with the parameters and script below, and send to it from a trigger action. A problem opens an alert in Amonit, its recovery resolves it, and Zabbix severity becomes the alert’s priority.

Set it up

  1. In Amonit, go to Integrations → Zabbix → Connect, pick the team that should be paged, and save. The integration’s page shows its URL, and the same parameters and script.
  2. In Zabbix, go to Alerts → Media types → Create media type. Name it Amonit, with type Webhook.
  3. Add these parameters (name = value). URL is the integration’s URL from Amonit, and event_url is optional:
URL           = https://yourteam.amonit.dev/api/v1/integrations/<token>/events
event_id      = {EVENT.ID}
event_value   = {EVENT.VALUE}
update_status = {EVENT.UPDATE.STATUS}
severity      = {EVENT.NSEVERITY}
severity_name = {EVENT.SEVERITY}
name          = {EVENT.NAME}
host          = {HOST.NAME}
trigger_id    = {TRIGGER.ID}
message       = {ALERT.MESSAGE}
tags          = {EVENT.TAGSJSON}
event_url     = https://<your zabbix>/tr_events.php?triggerid={TRIGGER.ID}&eventid={EVENT.ID}   (optional)
  1. Paste this script:
try {
    var params = JSON.parse(value),
        url = params.URL,
        req = new HttpRequest(),
        resp;

    delete params.URL;
    try { params.tags = JSON.parse(params.tags); } catch (e) { params.tags = []; }

    req.addHeader('Content-Type: application/json');
    resp = req.post(url, JSON.stringify(params));

    if (req.getStatus() < 200 || req.getStatus() >= 300) {
        throw 'Amonit answered ' + req.getStatus() + ': ' + resp;
    }

    return 'OK';
} catch (error) {
    Zabbix.log(3, '[ Amonit webhook ] ' + error);
    throw 'Amonit: ' + error;
}
  1. Give a user, such as an “Amonit” user, this media type, with any Send to value. In a trigger action, send to that user under both Operations and Recovery operations.

What happens

Zabbix sends Amonit
Problem ({EVENT.VALUE} 1) Opens an alert titled “<host>: <problem name>”. If the same event is sent again, it counts as a repeat and doesn’t page again.
Recovery ({EVENT.VALUE} 0), including a problem closed by hand Resolves the alert.
Update operation (acknowledge, comment, …) Ignored.
Zabbix severity Amonit priority
Disaster P1
High P2
Average P3
Warning P4
Information P5
Not classified P3
  • The alert keeps the event’s tags, message and trigger id. It links to the event in Zabbix when event_url is set.
  • The alert goes to the integration’s team, and that team’s escalation policy decides who gets the push and the phone call.
  • Failures show up in Zabbix. If Amonit doesn’t answer with a 2xx status, the script throws, so Zabbix records the notification as failed, with Amonit’s answer.

The media type follows Zabbix’s docs: webhook media type and supported macros.

Security

The URL contains the integration’s token, and anyone who has it can open alerts for that team. If it leaks, regenerate it on the integration’s page and update the URL parameter in Zabbix.

Limits

This setup follows Zabbix’s documentation. We haven’t yet run it against a live Zabbix server. If something doesn’t behave as described here, email [email protected].