wiki:influxdb

Version 6 (modified by krit, 2 years ago) (diff)

--

Influxdb

Ref here

To use grafana with influxdb, we set config OMD command with

omd config set PNP4NAGIOS off
omd config set GRAFANA on
omd config set INFLUXDB on
omd config set NAGFLUX on

Then on every host changed

#use                            generic-host,host-pnp
use                             generic-host,host-perf

On every service changed

#use                            generic-service,srv-pnp
use                             generic-service,srv-perf

Then, run omd reload

Export data to csv

OMD[monitor@3aa1bf04cbdd]:~$ influx -database nagflux -execute 'SELECT * FROM metrics' -format csv > test.csv

Select the lastest 2 value from metrics

OMD[monitor@1f46579684ec]:~/etc$ influx
Connected to http://127.0.0.1:8086 version 1.8.10
InfluxDB shell version: 1.8.10
> use nagflux
Using database nagflux
> SELECT * FROM metrics ORDER BY DESC LIMIT 2
name: metrics
time                 command          crit crit-fill host      max min performanceLabel service unit value warn warn-fill
----                 -------          ---- --------- ----      --- --- ---------------- ------- ---- ----- ---- ---------
2022-05-05T10:18:27Z check-host-alive                localhost         rtmin            ping    ms   0.014      
2022-05-05T10:18:27Z check-host-alive 5000 none      localhost     0   rta              ping    ms   0.028 3000 none
> 

We can select the field to show

> SELECT * FROM metrics WHERE host = 'kmitl' and service = 'ping' and unit = 'ms' ORDER BY DESC LIMIT 2
name: metrics
time                 command          crit crit-fill host  max min performanceLabel service unit value warn warn-fill
----                 -------          ---- --------- ----  --- --- ---------------- ------- ---- ----- ---- ---------
2022-05-05T10:24:53Z check-host-alive                kmitl         rtmin            ping    ms   5.407      
2022-05-05T10:24:53Z check-host-alive 5000 none      kmitl     0   rta              ping    ms   5.688 3000 none
> 

Query group by time

> SELECT mean(value) FROM metrics WHERE host = 'kmitl' and service = 'ping' and unit = 'ms' group by time(10m)