InfluxDB

Offline installation

Online installation is as easy as yum install -y influxdb.

But my use case is about offline installation. InfluxDB's programmed in Golang. So it's just a handful of binaries (influxd the daemon, influx the CLI...) that one can download from https://portal.influxdata.com/downloads as .tar.gz extract it over the / of any OS like above a busybox container and run it.

As for me I'm running CentOS, so the RPM will do just fine, it's including init script, user & group, directories... Here is a direct and most likely a soon deprecated link https://dl.influxdata.com/influxdb/releases/influxdb-1.5.3.x86_64.rpm

A bit of configuration, because offline means an angry & violent network admin.

sed -i 's;# reporting-disabled = false;reporting-disabled = true;' /etc/influxdb/influxdb.conf

RHEL6 equal iptables firewall, open it editing file /etc/sysconfig/iptables to add the following then service iptables reload

-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 8083 -j ACCEPT
-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 8086 -j ACCEPT

Start the service

service influxdb start
chkconfig on

Check the logs to make sure everything seems fine

 tail -f /var/log/influxdb/influxd.log

Database and user basics

Open cli locally with command influx, then you can create a database with create database YOUR_DB_NAME

root@centreon141:~# influx
Connected to http://localhost:8086 version 1.5.3
InfluxDB shell version: 1.5.3
> CREATE DATABASE centreon

And display it

> SHOW databases
name: databases
name
----
_internal
centreon

And work on it

USE centreon

Create an Admin user

CREATE USER admin WITH PASSWORD 'admin' WITH ALL PRIVILEGES

Create an user for a specific database

CREATE USER centreon WITH PASSWORD 'centreon'
GRANT ALL PRIVILEGES ON centreon TO centreon

One quick test, push a fake metric

curl -i -XPOST http://localhost:8086/write?db=centreon --data-binary "HARDWARE,CPU="1" value=91 1422568543702900257"

Which should answer the usual curl gibberish, including HTTP/1.1 204 No Content. Matched by

[httpd] ::1 - - [08/Jun/2018:12:26:02 +0200] "POST /write?db=test HTTP/1.1" 204 0 "-" "curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2" 582d552f-6b06-11e8-8036-000000000000 11974

in file /var/log/influxdb/influxd.log. Code 400 means it didn't worked properly.

See https://docs.influxdata.com/influxdb/latest/query_language/spec/ for more commands

WebUI

Chronograf replaced InfluxDB admin UI around version 1.1. One needs to install the whole TICK stack to get it running... RTFM here https://docs.influxdata.com/chronograf/v1.5/introduction/getting-started/, I'll summarize with : grab the RPMs

Upload them, then

yum localinstall *.rpm

Open iptables firewall, edit file /etc/sysconfig/iptables to add the following then service iptables reload

-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 8086 -j ACCEPT
-A INPUT -m state --state NEW,ESTABLISHED -m tcp -p tcp --dport 8888 -j ACCEPT    

Start the services

chkconfig influxdb on
chkconfig kapacitor on
chkconfig telegraf on
chkconfig chronograf on
service influxdb start
service kapacitor start
service telegraf start
service chronograf start

Then reach http://server:8888

Centreon

InfluxDB's library (still offline and missing this one) http://yum.centreon.com/standard/3.4/el6/stable/x86_64/RPMS/centreon-broker-influxdb-3.0.11-1.el6.x86_64.rpm to be installed like previously

As for configuration, I simply added another output to Centreon's central-broker-master, with the configuration taken from the example here https://github.com/centreon/centreon/issues/4058

<centreonbroker>
  <output>
    <type>influxdb</type>
    <name>centreon</name>
    <db_host>localhost</db_host>
    <db_port>8086</db_port>
    <db_user>centreon</db_user>
    <db_password>centreon</db_password>
    <db_name>centreon</db_name>
    <metrics_timeseries>centreon.metrics.$METRIC$</metrics_timeseries>
    <metrics_column>
      <name>host</name>
      <value>$HOST$</value>
      <is_tag>true</is_tag>
    </metrics_column>
    <metrics_column>
      <name>value</name>
      <value>$VALUE$</value>
      <type>number</type>
    </metrics_column>
    <status_timeseries>centreon.metrics.status</status_timeseries>
    <status_column>
      <name>host</name>
      <value>$HOST$</value>
      <is_tag>true</is_tag>
    </status_column>
    <status_column>
      <name>value</name>
      <value>$VALUE$</value>
      <type>number</type>
    </status_column>
  </output>
</centreonbroker>

Once the new output is saved, generate & reload poller configuration then manualy restart broker service service cbd restart.

To see something happening, tail -f /var/log/centreon-broker/*.log plus tail -f /var/log/influxdb/influxd.log. Centreon's central broker's informational & debug messages can be switched on for more stuff going on.

Wait a couple of minute, then check the data

curl -G 'http://localhost:8086/query' --data-urlencode 'db=centreon' --data-urlencode 'u=centreon&p=centreon' --data-urlencode 'q=SELECT mean("value") AS "mean_value" FROM "centreon"."autogen"."centreon.status1.Ping" WHERE time > now() - 1h GROUP BY time(5s) FILL(null)'

Which can also be done via influx cli, here locally so no need for host, -username, -password ...

influx -execute 'SELECT mean("value") AS "mean_value" FROM "centreon"."autogen"."centreon.status1.Ping" WHERE time > now() - 1h GROUP BY time(5s) FILL(null)'