116 lines
3.7 KiB
Markdown
116 lines
3.7 KiB
Markdown
|
---
|
||
|
categories: monitoring
|
||
|
title: Howto InfluxDB
|
||
|
...
|
||
|
|
||
|
* Documentation : <https://docs.influxdata.com/influxdb>
|
||
|
|
||
|
[InfluxDB](https://www.influxdata.com/time-series-platform/influxdb/) est une base de données de séries temporelles. Nous l'utilisons en combinaison avec [collectd](HowtoCollectd) et [Grafana](HowtoGrafana).
|
||
|
|
||
|
|
||
|
## Installation
|
||
|
|
||
|
Nous utilisons les dépôts fournis par InfluxData pour avoir une version stable plus récente.
|
||
|
|
||
|
~~~
|
||
|
# curl -sL https://repos.influxdata.com/influxdb.key | apt-key add -
|
||
|
# echo "deb https://repos.influxdata.com/debian stretch stable" > /etc/apt/sources.list.d/influxdb.list
|
||
|
# apt update
|
||
|
# apt install influxdb
|
||
|
# systemctl start influxdb.service
|
||
|
|
||
|
$ influx -version
|
||
|
InfluxDB shell version: 1.5.2
|
||
|
|
||
|
$ systemctl status influxdb
|
||
|
● influxdb.service - InfluxDB is an open-source, distributed, time series database
|
||
|
Loaded: loaded (/lib/systemd/system/influxdb.service; enabled; vendor preset: enabled)
|
||
|
Docs: https://docs.influxdata.com/influxdb/
|
||
|
Main PID: 2351 (influxd)
|
||
|
Tasks: 9 (limit: 4915)
|
||
|
CGroup: /system.slice/influxdb.service
|
||
|
└─2351 /usr/bin/influxd -config /etc/influxdb/influxdb.conf
|
||
|
~~~
|
||
|
|
||
|
## Configuration
|
||
|
|
||
|
La configuration par défaut convient et ne nécessite que peu de modifications. On peut désactiver la collection de statistiques internes à InfluxDB, et ne faire écouter le serveur HTTP qu'en local. Ce dernier permet d'afficher des graphes à des fins de tests uniquement.
|
||
|
|
||
|
~~~
|
||
|
[monitor]
|
||
|
store-enabled = false
|
||
|
[http]
|
||
|
bind-address = "127.0.0.1:8086"
|
||
|
~~~
|
||
|
|
||
|
### Collectd
|
||
|
|
||
|
Pour récupérer les métriques envoyées par [collectd](HowtoCollectd), il suffit d'activer le listener :
|
||
|
|
||
|
~~~
|
||
|
[[collectd]]
|
||
|
enabled = true
|
||
|
bind-address = ":25826"
|
||
|
database = "collectd"
|
||
|
typesdb = "/usr/share/collectd"
|
||
|
~~~
|
||
|
|
||
|
## Administration
|
||
|
|
||
|
Il peut être intéressant de naviguer dans la base de données afin de comprendre comment sont stockées les données, et ainsi afficher des graphes avec plus de facilité :
|
||
|
|
||
|
~~~
|
||
|
# influx
|
||
|
Connected to http://localhost:8086 version 1.5.2
|
||
|
InfluxDB shell version: 1.5.2
|
||
|
> SHOW DATABASES
|
||
|
name: databases
|
||
|
name
|
||
|
----
|
||
|
collectd
|
||
|
> USE collectd
|
||
|
Using database collectd
|
||
|
> SHOW MEASUREMENTS
|
||
|
name: measurements
|
||
|
name
|
||
|
----
|
||
|
cpu_value
|
||
|
disk_value
|
||
|
load_longterm
|
||
|
load_midterm
|
||
|
load_shortterm
|
||
|
snmp_rx
|
||
|
snmp_tx
|
||
|
tcpconns_value
|
||
|
> SELECT * FROM snmp_rx,snmp_tx LIMIT 5
|
||
|
name: snmp_rx
|
||
|
time host type type_instance value
|
||
|
---- ---- ---- ------------- -----
|
||
|
1527610980434511472 Switch if_packets machine A 4241766500
|
||
|
1527611039463879536 Switch if_octets machine B 9414616763688
|
||
|
1527611039463903506 Switch if_octets machine C 59780133577
|
||
|
1527611039463953500 Switch if_octets machine D 109232798624
|
||
|
1527611039556165882 Switch if_packets machine B 7925165702
|
||
|
|
||
|
name: snmp_tx
|
||
|
time host type type_instance value
|
||
|
---- ---- ---- ------------- -----
|
||
|
1527610980434511472 Switch if_packets machine A 11434830808
|
||
|
1527611039463879536 Switch if_octets machine B 174654547558
|
||
|
1527611039463903506 Switch if_octets machine C 135392659943
|
||
|
1527611039463953500 Switch if_octets machine D 9179809568001
|
||
|
1527611039556165882 Switch if_packets machine B 396998647
|
||
|
~~~
|
||
|
|
||
|
On peut vouloir supprimer une mesure particulière, par exemple dans le cas où une machine n'est plus sur le switch :
|
||
|
|
||
|
~~~
|
||
|
> SHOW SERIES FROM snmp_rx,snmp_tx WHERE type_instance='machine A'
|
||
|
key
|
||
|
---
|
||
|
snmp_rx,host=Switch,type=if_octets,type_instance=machine\ A
|
||
|
snmp_rx,host=Switch,type=if_packets,type_instance=machine\ A
|
||
|
snmp_tx,host=Switch,type=if_octets,type_instance=machine\ A
|
||
|
snmp_tx,host=Switch,type=if_packets,type_instance=machine\ A
|
||
|
> DROP SERIES FROM snmp_rx,snmp_tx WHERE type_instance='machine A'
|
||
|
~~~
|