LMacPhail / zabbix-history-influxdb

A loadable module for zabbix which will export history data to an InfluxDB repository.
GNU General Public License v2.0
44 stars 15 forks source link

Zabbix module to store history in InfluxDB

Zabbix module mirroring all history data to InfluxDB in real-time. It provides enhanced performance and easier usage with Grafana.

Zabbix -> InfluxDB -> Grafana

Features

This is what you get in Grafana:

example of grafana graphs

And how the data is queried:

querying the data in grafana

Installation

First find a place to put the Zabbix module. If your version of Zabbix is installed from packages, a good option may be /usr/lib/zabbix/modules. Create the directory if doesn't exist.

mkdir /usr/lib/zabbix/modules
cd /usr/lib/zabbix/modules

Download:

Edit downloaded history_influxdb.conf to meet your needs (InfluxDB address, name, protocol, etc.), the only mandatory value to put in is InfluxDBName.

Now edit the main Zabbix server configuration file, usually in /etc/zabbix/zabbix_server.conf and change the modules section near the end to point to your module:

LoadModulePath=/usr/lib/zabbix/modules
...
LoadModule=history_influxdb.so

Restart Zabbix server daemon, usually:

systemctl restart zabbix-server

Open Zabbix log to spot any errors, usually /var/log/zabbix_server.log.

Now you should be able to see all the Zabbix data in InfluxDB and Grafana (if you have your datasource set).

Security and Sustainability

Please consider using authorization with InfluxDB as described on https://docs.influxdata.com/influxdb/latest/administration/authentication_and_authorization/#authorization.

The above has no real point if you don't use HTTPS. In order to do so, follow the instructions to set up a certificate and key on https://docs.influxdata.com/influxdb/latest/administration/https_setup/.

Please consider some Downsampling and data retention strategies in Influx.

Don't forget to maintain your Zabbix history by either build-in House keeping process or with table partitioning.

Data format

<metric_str>,host_name=<str>,host_groups=<str>[,applications=<str>] value=<float|int|str> <timestamp>

Example of the payload sent to InfluxDB including escaping. Internally cURL is used to POST values to a URL similar to http://localhost:8086/write?db=name_of_your_db (constructed from history_influxdb.conf values). More information on writing to Influx using cURL can be found at https://docs.influxdata.com/influxdb/latest/guides/writing_data/

Zabbix\ configuration\ cache\,\ %\ free,host_name=Zabbix\ server,host_groups=Zabbix\ servers,applications=Zabbix\ server value=96.181583 1536077504941543030
Total\ memory,host_name=Zabbix\ server,host_groups=Zabbix\ servers,applications=Memory value=2090303488 1536077503940736386

Background

We like to use Grafana to browse data from various monitoring sources and to create custom dashboards. The easiest way to integrate Zabbix with Grafana is to use a Grafana plug-in that directly hits Zabbix. However, this may jeopardize Zabbix if there are too many complicated requests from Grafana (and it's users).

Imagine some users (let's say 20 guys) are looking into data using Grafana and displaying history of last 90 days or having the last 1 hour refreshed every 10s to have a live view. This will generate exhaustive load on database backend, effectively blocking new values from being written on time.

Motivation for this module was to offer data collected by Zabbix for analysis and extensive querying to the wider audience. Our solution to this is to split Zabbix database backend and Grafana data source into two independent data stores, we have chosen InfluxDB for it's simplicity and focus on time series data, but other options here may be Elastic, Graphite or Prometheus.

Since Zabbix 3.2.0 we may use a module to handle history data, this project leverage this to forward data to InfluxDB.

Inspiration for this module originates from and credit goes to:

Compatibility and limitations

Development

Please see separate document on development

Contributors