Skip to content

Latest commit

 

History

History

README.md

Agent Check: Zabbix

Overview

Connect to Zabbix to:

  • Monitor Zabbix through the Datadog Agent.
  • Send Zabbix alerts to Datadog to see the alerts as events in your Datadog event stream.

Setup

The Zabbix check is not included in the Datadog Agent package, so you need to install it.

Installation

For Agent v7.21+ / v6.21+, follow the instructions below to install the Zabbix check on your host. See Use Community Integrations to install with the Docker Agent or earlier versions of the Agent.

  1. Run the following command to install the Agent integration:

    datadog-agent integration install -t datadog-zabbix==<INTEGRATION_VERSION>
  2. Configure your integration similar to core integrations.

Configuration

  1. Make sure that your Zabbix server timezone is set to UTC. More information about Zabbix time zones can be found on the Zabbix documentation.

  2. Edit the zabbix.d/conf.yaml file, in the conf.d/ folder at the root of your Agent's configuration directory to start collecting your Zabbix performance data. See the sample zabbix.d/conf.yaml for all available configuration options.

  3. Restart the Agent.

Event collection

Create Datadog media type
  1. Navigate to Administration > Media Types > Create Media Type.
  2. Add parameters to the webhook using Zabbix template variables. Add your Datadog api_key and the following Zabbix template variables as parameters:
Parameter Value
api_key Your Datadog API key
event_date {EVENT.DATE}
event_name {EVENT.NAME}
event_nseverity {EVENT.NSEVERITY}
event_tags {EVENT.TAGSJSON}
event_time {EVENT.TIME}
event_value {EVENT.VALUE}
item_name {ITEM.NAME}
alert_message {ALERT.MESSAGE}
alert_subject {ALERT.SUBJECT}
  1. Set Name to Datadog, Type to Webhook, and input the following code as the Script:
try {
	Zabbix.Log(4, '[datadog webhook] received value=' + value);

	var params = JSON.parse(value);
	var req = new HttpRequest();
	req.addHeader('Content-Type: application/json');
	var webhook_url = 'https://app.datadoghq.com/intake/webhook/zabbix?api_key=' + params.api_key;
	var webhook_data = value;
	var resp = req.post(webhook_url, webhook_data);
	if (req.getStatus() != 202) {
		throw 'Response code: '+req.getStatus();
	}
	Zabbix.Log(4, '[datadog webhook] received response with status code ' + req.getStatus() + '\n' + resp);
} catch (error) {
	Zabbix.Log(4, '[datadog webhook] event creation failed json : ' + webhook_data)
	Zabbix.Log(4, '[datadog webhook] event creation failed : ' + error);
}
return JSON.stringify({});

  1. Validate the Webhook is set up correctly by using the "Test" button.
Assign Webhook media to an existing user
  1. After configuring the Webhook media type, navigate to Administration > Users and create a dedicated Zabbix user to represent the Webhook. For example, use the alias Datadog for the Datadog Webhook. All settings, except media, can be left at their defaults as this user does not log in to Zabbix.
  2. In the user profile, go to a Media tab and add a Webhook with the required contact information. If the Webhook does not use a send to field, enter any combination of supported characters to bypass validation requirements.
  3. Grant this user at least read permissions to all hosts for which it should send the alerts.
Configure an alert action for the Webhook
  1. Navigate to Configuration > Actions.
  2. From the page title dropdown, select the required action type.
  3. Click on Create Action.
  4. Name the action.
  5. Choose conditions upon which operations are carried out.
  6. Choose the operations to carry out.

Validation

Run the Agent's status subcommand and look for zabbix under the Checks section.

Data Collected

Metrics

See metadata.csv for a list of metrics provided by this check.

Events

Zabbix alerts are collected as events in the Datadog event stream.

Service Checks

See service_checks.json for a list of service checks provided by this integration.

Trigger on-call pages

Configure a Zabbix Webhook media type to forward triggers to the Datadog events intake, which routes them to Datadog On-Call using an oncall_team query parameter. Datadog deduplicates and auto-resolves events that share an aggregation_key, so a Zabbix OK resolves the page created by the corresponding PROBLEM automatically.

Map Zabbix triggers to on-call pages

Zabbix {EVENT.VALUE} {EVENT.NSEVERITY} Event category Alert status On-Call effect
1 (PROBLEM) 5 Disaster alert error Pages the configured On-Call team
1 (PROBLEM) 4 High alert error Pages the configured On-Call team
1 (PROBLEM) 3 Average alert warn Pages the configured On-Call team
1 (PROBLEM) 2 Warning alert warn Pages the configured On-Call team
1 (PROBLEM) 0-1 Not classified, Information alert warn Pages the configured On-Call team
0 (OK) n/a alert ok Resolves the page with the same aggregation_key

Setup

Create the on-call media type

  1. Navigate to Administration > Media Types > Create Media Type.
  2. Set Name to Datadog On-Call and Type to Webhook.
  3. Add the following parameters:
Parameter Value
dd_api_key <YOUR_DATADOG_API_KEY>
dd_site datadoghq.com
oncall_team <YOUR_ONCALL_TEAM_HANDLE>
event_value {EVENT.VALUE}
event_nseverity {EVENT.NSEVERITY}
event_name {EVENT.NAME}
host_name {HOST.NAME}
trigger_id {TRIGGER.ID}
alert_message {ALERT.MESSAGE}

Set dd_site to your Datadog site, for example, datadoghq.eu or us3.datadoghq.com. Set oncall_team to the team handle configured in Datadog On-Call, without the @oncall- prefix.

  1. Input the following code as the Script:
try {
    var params = JSON.parse(value);
    var problem = params.event_value === '1';
    var nseverity = parseInt(params.event_nseverity, 10);

    var status = 'warn';
    if (!problem) {
        status = 'ok';
    } else if (nseverity >= 4) {
        status = 'error';
    }

    var payload = {
        data: {
            type: 'event',
            attributes: {
                category: 'alert',
                title: 'Zabbix: ' + params.host_name + ' - ' + params.event_name,
                message: params.alert_message,
                integration_id: 'zabbix',
                aggregation_key: 'zabbix:' + params.host_name + ':' + params.trigger_id,
                tags: ['integration:zabbix', 'host:' + params.host_name],
                attributes: { status: status },
                zabbix: { source: 'zabbix-server' }
            }
        }
    };

    var url = 'https://event-management-intake.' + params.dd_site +
              '/api/v2/events/webhook?dd-api-key=' + encodeURIComponent(params.dd_api_key) +
              '&integration_id=zabbix&oncall_team=' + encodeURIComponent(params.oncall_team);

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

    if (req.getStatus() < 200 || req.getStatus() >= 300) {
        throw 'Datadog On-Call notification failed: HTTP ' + req.getStatus() + ' ' + resp;
    }
} catch (error) {
    Zabbix.Log(4, '[datadog oncall] ' + error);
    throw error;
}
return JSON.stringify({});
  1. Validate the webhook is set up correctly by using the Test button.

Assign the media to a user

Follow the same steps as in Assign Webhook media to an existing user above. The dedicated Datadog user can host both media types.

Configure an alert action

Create a Zabbix action targeting the Datadog On-Call media type. Make sure the action is enabled both on the PROBLEM (firing) and on the Recovery event so that resolutions reach Datadog and the corresponding On-Call page auto-resolves.

Verify pages appear under On-Call > Pages in Datadog.

Troubleshooting

Need help? Contact Datadog support.