zabbix grafana influxdb 20.04 18.04 16.04
I’m not particularly fond of influxdb
, but since I know
it already and since any time-series database should work better than a standard SQL
database for time-series, let’s try to store zabbix history into influxdb
.
Setup
- Install zabbix.
- Install grafana.
- Install influxdb and configure authentication.
- Install
go
andpwgen
:sudo apt-get install golang-go pwgen
- Follow the chapter about your SQL database on https://github.com/zensqlmonitor/influxdb-zabbix.
- Connect to influx, create the
zabbix
database, with thezabbix
user for writing andzabbix_ro
user for read-only access (from grafana).CREATE database zabbix CREATE USER zabbix WITH PASSWORD 'use pwgen for that field and take a note' CREATE USER zabbix_ro WITH PASSWORD 'use pwgen for that field and take another note' GRANT ALL ON zabbix TO zabbix GRANT READ on zabbix TO zabbix_ro
- Create a user
zabbix-influx
sudo useradd -g zabbix -d /var/lib/zabbix-influx zabbix-influx sudo chown -R zabbix-influx:zabbix /var/lib/zabbix-influx
- Using the
zabbix-influx
user, installgithub.com/zensqlmonitor/influxdb-zabbix
sudo -u zabbix-influx go get github.com/zensqlmonitor/influxdb-zabbix sudo -u zabbix-influx cp go/src/github.com/zensqlmonitor/influxdb-zabbix/influxdb-zabbix.conf .
- Configure influx credentials, and SQL access using
sudoedit /var/lib/zabbix-influx/influxdb-zabbix.conf
, make sure to configure influx and mysql URLs, databases, users and password.
Testing
- This command will run the influxd-zabbix in foreground:
sudo -u zabbix-influx -i go build github.com/zensqlmonitor/influxdb-zabbix go install github.com/zensqlmonitor/influxdb-zabbix ./go/bin/influxdb-zabbix
In fact, it will take all zabbix history and trends and put then into influx.
- Go to grafana, configure a new source using influxdb, database:zabbix, user:zabbix_ro, …
- Still in grafana, create a new dashboard and test the new data source.
- When all is working, kill
influxdb-zabbix
using CTRL-C.
Service
Now that the zabbix to influx bridge is working, make sur it runs in background, so data are pushed into influx as soon as they are in zabbix.
- Reduce the verbosity and disable coloring for syslog:
sudoedit /var/lib/zabbix-influx/influxdb-zabbix.conf
and change:levelconsole="Warn" formatting=false
- Create the service file, using
sudoedit /etc/systemd/system/zabbix-influx.service
with the following content:[Unit] Description=zabbix to influx data pusher # [Service] Type=simple Restart=always RestartSec=5s ExecStart=/var/lib/zabbix-influx/go/bin/influxdb-zabbix User=zabbix-influx Group=zabbix WorkingDirectory=~ # [Install] WantedBy=multi-user.target
- Update systemd services
sudo systemctl daemon-reload
- Enable and start the service
sudo systemctl enable zabbix-influx sudo systemctl start zabbix-influx
- Check
systemctl status zabbix-influx.service
Should be Active (running).
- Have a break, then return to grafana and check if data are up-to date.
~~~
Question, remark, bug? Don't hesitate to contact me or report a bug.