Skip to content

Zabbix provisioner to automatically create host/items/triggers from Prometheus rules

Notifications You must be signed in to change notification settings

gmauleon/alertmanager-zabbix-provisioner

Repository files navigation

Build Status

DEPRECATED

Hey guys, I don`t have much time to properly work on this project anymore since I'm not using Zabbix in my pipelines as of late. I would gladely point/link to a fork if you guys have a maintained and living project for that. Thanks Guys. And sorry about that.

alertmanager-zabbix-provisioner

The provisioner will connect to your prometheus to get the current configured rules and will create a host/items/triggers accordingly
Data for those items can then be sent via a webhook: https://github.com/gmauleon/alertmanager-zabbix-webhook

The concept is to use annotations in prometheus rules, along with a provisionner configuration file to automatically create everything in Zabbix

Howto

Have a look at the default config.yaml for the possible parameters
Kubernetes examples manifests can be found here: https://github.com/gmauleon/alertmanager-zabbix-provisioner/tree/master/contrib/kubernetes

To create a host with items/triggers in Zabbix, your prometheus rule need to have some annotations matching your selector configuration for that host
For example that configuration:

zabbixHosts:
  - name: gmauleon-test01
    selector:
      zabbix: gmauleon-test01

Will match rules like:

ANNOTATIONS {
  zabbix = "gmauleon-test01",
  summary = "Alerting DeadMansSwitch",
  description = "This is a DeadMansSwitch meant to ensure that the entire Alerting pipeline is functional.",
}

You can choose what Prometheus rule appear in Zabbix with that behavior.

In Zabbix, fields for an item are populated following the behavior below:
Name = rule name
Description = zabbix_description annotation OR description annotation OR empty
Applications = zabbix_applications annotation OR itemDefaultApplication configuration
History storage period = zabbix_history annotation OR itemDefaultHistory configuration
Trend storage period = zabbix_trend annotation OR itemDefaultTrends configuration
Allowed hosts = zabbix_trapper_hosts annotation OR itemDefaultTrapperHosts configuration

Fields for triggers are populated:

Name = zabbix_trigger_name annotation OR summary annotation OR rule name
Description = zabbix_trigger_description annotation OR description annotation OR empty
Severity = zabbix_trigger_severity annotation OR not classified

There is a special annotations called zabbix_trigger_nodata which will add a nodata condition on the item in Zabbix
The value of zabbix_trigger_nodata corresponds to the time in seconds after when the trigger will fire if no data is send to this item

ANNOTATIONS {
  zabbix = "gmauleon-test01",
  zabbix_trigger_nodata = "100",
  summary = "Node status is NotReady",
  description = "The Kubelet on {{ $labels.node }} has not checked in with the API, or has set itself to NotReady, for more than an hour",
}

Examples in prometheus:

ANNOTATIONS {
  zabbix = "gmauleon-test01",
  zabbix_history = "7d",
  zabbix_applications = "kubelet,prometheus,alertmanager",
  zabbix_trigger_severity = "critical",
  zabbix_description = "One of the Kubelet has not checked in with the API",
  summary = "Node status is NotReady",
  description = "The Kubelet on {{ $labels.node }} has not checked in with the API, or has set itself to NotReady, for more than an hour",
}

Limitations

For now a minimal scraper, parse the html page that expose rules on your Prometheus (which is pretty clumsy :( )
Note that the HTML page exposed by prometheus currently does not resolve variables, so it's better to use the dedicated Zabbix annotations not to have variables names in your Zabbix items...
Ultimately, this will be replaced by the rules API endpoint, see prometheus/prometheus#2600

Since host groups and hosts are declared in the provisionner configuration, there will not be deleted automatically (since I don't have any state saved anywhere).
So you'll have to delete those by hands in Zabbix if you remove some

About

Zabbix provisioner to automatically create host/items/triggers from Prometheus rules

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published