Integration with Zabbix

In this tutorial, you will learn how to configure Zabbix to forward alerts to Alerta using the zabbix-alerta integration package.

Contents

Overview

The zabbix-alerta package provides an alert script that Zabbix calls when a trigger fires. Zabbix severities are mapped to Alerta severities as follows:

Zabbix Severity

Alerta Severity

Disaster

critical

High

major

Average

minor

Warning

warning

Information

informational

Not classified

indeterminate

OK (resolved)

normal

Prerequisites

Before you begin, you should have:

  • Zabbix Server 4.0 or later

  • A running Alerta server (see Using Docker to deploy Alerta)

  • An Alerta API key with write:alerts scope

  • Python 3.6+ on the Zabbix server

Step 1: Install zabbix-alerta

Install the integration package on your Zabbix server:

$ pip install zabbix-alerta

Find the Zabbix AlertScriptsPath by checking the Zabbix server configuration:

$ grep AlertScriptsPath /etc/zabbix/zabbix_server.conf
AlertScriptsPath=/usr/lib/zabbix/alertscripts

Create a symlink so Zabbix can find the script:

$ ln -s $(which zabbix-alerta) /usr/lib/zabbix/alertscripts/

Step 2: Configure the alert script

Create a configuration file at /etc/alerta/zabbix-alerta.conf:

[alerta]
endpoint = http://alerta.example.com:8080/api
key = your-api-key-here
environment = Production

Test the script from the command line to verify connectivity:

$ zabbix-alerta --endpoint http://alerta.example.com:8080/api \
    --key your-api-key-here \
    --environment Development \
    --severity warning \
    --resource zabbix-test \
    --event "Test Trigger" \
    --text "Testing zabbix-alerta integration"

Step 3: Create a Zabbix media type

In the Zabbix web UI, navigate to Administration > Media types and create a new media type:

  • Name: Alerta

  • Type: Script

  • Script name: zabbix-alerta

  • Script parameters:

    1. {ALERT.SENDTO}

    2. {ALERT.SUBJECT}

    3. {ALERT.MESSAGE}

Then assign the Alerta media type to a Zabbix user under Administration > Users. Set the Send to field to the Alerta API endpoint URL.

Step 4: Create an action

Navigate to Configuration > Actions and create a new trigger action:

  • Name: Send to Alerta

  • Conditions: Select the trigger severities you want to forward

  • Operations: Add an operation that sends a message to the user configured in Step 3

For the Default message, use the following template so the integration script can parse trigger details:

resource={HOST.NAME}
event={TRIGGER.NAME}
environment=Production
severity={TRIGGER.SEVERITY}
status={TRIGGER.STATUS}
value={TRIGGER.VALUE}
text={ITEM.LASTVALUE}
tags=zabbix,{TRIGGER.TAGS}

Set the Recovery message similarly, but with status=OK.

Step 5: Test the integration

Create a simple test trigger in Zabbix on a monitored host, or use the Zabbix zabbix_sender utility to push a test value that triggers an existing threshold:

$ zabbix_sender -z zabbix-server -s "test-host" -k test.key -o 100

Check the Alerta web UI or CLI to verify the alert was received:

$ alerta query --filter resource=test-host

Once confirmed, you can disable or remove the test trigger.

Next Steps