Icinga2 mit Grafana und Influxdb: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(20 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt)
Zeile 3: Zeile 3:
  
 
=InfluxDB=
 
=InfluxDB=
*apt-get install influxdb influxdb-client
+
*wget https://dl.influxdata.com/influxdb/releases/influxdb_1.2.2_amd64.deb
 +
*sudo dpkg -i influxdb_1.2.2_amd64.deb
 +
*apt-get install influxdb-client
 +
 
 
<pre>
 
<pre>
 
root@localhost:~# influx
 
root@localhost:~# influx
Zeile 9: Zeile 12:
 
InfluxDB shell version: 0.13.0
 
InfluxDB shell version: 0.13.0
 
> create database icinga2;
 
> create database icinga2;
> create user icinga2 with password ‘geheim’;
+
> create user icinga2 with password 'geheim';
 
> grant all on icinga2 to icinga2;
 
> grant all on icinga2 to icinga2;
 
</pre>
 
</pre>
  
*vi /etc/icinga2/features-enabled/influxdb.conf
+
*vi /etc/icinga2/features-available/influxdb.conf
 
<pre>
 
<pre>
    object InfluxdbWriter "influxdb" {
+
library "perfdata"
    host = "127.0.0.1"
 
    port = 8086
 
    database = "icinga2"
 
    username = "icinga2"
 
    password = "geheim"
 
    enable_send_thresholds = true
 
    enable_send_metadata = true
 
    host_template = {
 
    measurement = “$host.check_command$”
 
    tags = {
 
    hostname = “$host.name$”
 
    }
 
    }
 
  
    service_template = {
+
object InfluxdbWriter "influxdb" {
    measurement = $service.check_command$
+
  host = "127.0.0.1"
    tags = {
+
  port = 8086
    hostname = $host.name$
+
  database = "icinga2"
    service = $service.name$
+
  username = "icinga2"
    }
+
  password = "sysadm"
    }
+
  enable_send_thresholds = true
 +
  enable_send_metadata = true
 +
  host_template = {
 +
  measurement = "$host.check_command$"
 +
  tags = {
 +
  hostname = "$host.name$"
 +
  }
 +
  }
 +
  service_template = {
 +
  measurement = "$service.check_command$"
 +
  tags = {
 +
  hostname = "$host.name$"
 +
  service = "$service.name$"
 +
  }
 +
  }
 +
}
 +
</pre>
  
    }
+
===Connect Icinga2 to HTTPS-Influxdb===
 +
*In diesem Fall muss noch der Eintrag "ssl_enable = true" hinzugefügt werden
 +
*vi /etc/icinga2/features-available/influxdb.conf
 +
<pre>
 +
library "perfdata"
 +
 
 +
object InfluxdbWriter "influxdb" {
 +
  host = "127.0.0.1"
 +
  port = 8086
 +
  ssl_enable = true
 +
  database = "icinga2"
 +
  username = "icinga2"
 +
  password = "sysadm"
 +
  enable_send_thresholds = true
 +
  enable_send_metadata = true
 +
  host_template = {
 +
  measurement = "$host.check_command$"
 +
  tags = {
 +
  hostname = "$host.name$"
 +
  }
 +
  }
 +
  service_template = {
 +
  measurement = "$service.check_command$"
 +
  tags = {
 +
  hostname = "$host.name$"
 +
  service = "$service.name$"
 +
  }
 +
  }
 +
}
 
</pre>
 
</pre>
  
 
==Feature enabled==
 
==Feature enabled==
 
*icinga2 feature enable influxdb
 
*icinga2 feature enable influxdb
 +
*systemctl restart icinga2.service
  
 
=Grafana=
 
=Grafana=
Zeile 54: Zeile 89:
 
*apt-get install grafana
 
*apt-get install grafana
 
*systemctl start grafana-server
 
*systemctl start grafana-server
 +
 +
==Module hinzufügen==
 +
*cd /usr/share/icingaweb2/modules
 +
*git clone https://github.com/Mikesch-mp/icingaweb2-module-grafana.git grafana
 +
 +
==Module enabled==
 +
*icingacli module enable grafana
 +
*systemctl restart icinga2.service
 +
 +
==Configuration==
 +
*vi /etc/icingaweb2/modules/grafana/config.ini
 +
<pre>
 +
[grafana]
 +
username = "icinga2"
 +
host = "hostname:3000"
 +
protocol = "http"
 +
password = "geheim"
 +
height = "280"
 +
width = "640"
 +
timerange = "3h"
 +
enableLink = "yes"
 +
defaultdashboard = "icinga2-default"
 +
datasource = "influxdb"
 +
defaultdashboardstore = "db"
 +
accessmode = "direct"
 +
directrefresh = "yes"
 +
</pre>
 +
 +
*vi /etc/icingaweb2/modules/grafana/graphs.ini
 +
<pre>
 +
[icinga2 default]
 +
dashboard = "icinga2-default.json"
 +
panelId = "1"
 +
height = "280"
 +
width = "460"
 +
</pre>
 +
 +
==Im Grafana-Webinterface==
 +
 +
===Influxdb hinzufügen===
 +
*Klick auf das Grafana-Symbol und im sich öffnenden Menü auf "Data Source"
 +
[[Datei:influxdb-icinga2-1.png]]
 +
*In dem sich öffnenden Bildschirm auf "Add Data Source" klicken
 +
[[Datei:influxdb-icinga2-2.png]]
 +
*Wie im unteren Screenshot die Daten ausfüllen und auf "Save & Test" klicken
 +
[[Datei:influxdb-icinga2-3.png]]
 +
 +
===Dashboard downloaden===
 +
*https://grafana.com/api/dashboards/381/revisions/1/download
 +
===Dashboard hinzufügen===
 +
*Klick auf das Grafana-Symbol und im sich öffnenden Menü auf "Dashboards"
 +
[[Datei:Influxdb-icinga2-1.png]]
 +
*Im sich öffnenden Bildschirm auf "Home" und im sich öffnenden Menü unten auf "Import"
 +
[[Datei:Dashboard-icinga2-2.png]]
 +
*Nun auf "Upload .json File" und die weiter oben herunter geladene Datei auswählen und auf "load" klicken
 +
[[Datei:Dashboard-icinga2-3.png]]
 +
*Unbedingt im Feld "Name" "icinga2-default" eintragen und bei InfluxDB "icinga2" auswählen und auf "Import" klicken
 +
[[Datei:Dashboard-icinga2-4.png]]
 +
 +
==Im Icinga2-Webinterface==
 +
'''''Der folgende Vorgang muss für jeden einzellnen Graphen im Dashboard wiederholt werden!'''''
 +
*Links auf "Configuration" und dort auf "Grafana Graphs"
 +
[[Datei:icingaweb2-grafana-1.png]]
 +
*Es müsste eine Liste der bereits vorhandenen Grafana Graphen erscheinen über der sich wie im unteren Screenshot der Button "Add Grafana Graph" befinden müsste
 +
[[Datei:icingaweb2-grafana-2.png]]
 +
*Das sich öffnende Formular wie unten ausfüllen und auf "Add Graph" klicken
 +
[[Datei:icingaweb2-grafana-3.png]]
 +
 +
=Centos=
 +
*http://vmkdaily.ghost.io/influxdb-and-grafana-on-centos/

Aktuelle Version vom 19. Mai 2017, 08:21 Uhr

Vorraussetzungen

InfluxDB

root@localhost:~# influx
Connected to http://localhost:8086 version 0.13.0
InfluxDB shell version: 0.13.0
> create database icinga2;
> create user icinga2 with password 'geheim';
> grant all on icinga2 to icinga2;
  • vi /etc/icinga2/features-available/influxdb.conf
library "perfdata"

object InfluxdbWriter "influxdb" {
  host = "127.0.0.1"
  port = 8086
  database = "icinga2"
  username = "icinga2"
  password = "sysadm"
  enable_send_thresholds = true
  enable_send_metadata = true
  host_template = {
  measurement = "$host.check_command$"
  tags = {
  hostname = "$host.name$"
  }
  }
  service_template = {
  measurement = "$service.check_command$"
  tags = {
  hostname = "$host.name$"
  service = "$service.name$"
  }
  }
}

Connect Icinga2 to HTTPS-Influxdb

  • In diesem Fall muss noch der Eintrag "ssl_enable = true" hinzugefügt werden
  • vi /etc/icinga2/features-available/influxdb.conf
library "perfdata"

object InfluxdbWriter "influxdb" {
  host = "127.0.0.1"
  port = 8086
  ssl_enable = true
  database = "icinga2"
  username = "icinga2"
  password = "sysadm"
  enable_send_thresholds = true
  enable_send_metadata = true
  host_template = {
  measurement = "$host.check_command$"
  tags = {
  hostname = "$host.name$"
  }
  }
  service_template = {
  measurement = "$service.check_command$"
  tags = {
  hostname = "$host.name$"
  service = "$service.name$"
  }
  }
}

Feature enabled

  • icinga2 feature enable influxdb
  • systemctl restart icinga2.service

Grafana

Installation

Module hinzufügen

Module enabled

  • icingacli module enable grafana
  • systemctl restart icinga2.service

Configuration

  • vi /etc/icingaweb2/modules/grafana/config.ini
[grafana]
username = "icinga2"
host = "hostname:3000"
protocol = "http"
password = "geheim"
height = "280"
width = "640"
timerange = "3h"
enableLink = "yes"
defaultdashboard = "icinga2-default"
datasource = "influxdb"
defaultdashboardstore = "db"
accessmode = "direct"
directrefresh = "yes"
  • vi /etc/icingaweb2/modules/grafana/graphs.ini
[icinga2 default]
dashboard = "icinga2-default.json"
panelId = "1"
height = "280"
width = "460"

Im Grafana-Webinterface

Influxdb hinzufügen

  • Klick auf das Grafana-Symbol und im sich öffnenden Menü auf "Data Source"

Influxdb-icinga2-1.png

  • In dem sich öffnenden Bildschirm auf "Add Data Source" klicken

Influxdb-icinga2-2.png

  • Wie im unteren Screenshot die Daten ausfüllen und auf "Save & Test" klicken

Influxdb-icinga2-3.png

Dashboard downloaden

Dashboard hinzufügen

  • Klick auf das Grafana-Symbol und im sich öffnenden Menü auf "Dashboards"

Influxdb-icinga2-1.png

  • Im sich öffnenden Bildschirm auf "Home" und im sich öffnenden Menü unten auf "Import"

Dashboard-icinga2-2.png

  • Nun auf "Upload .json File" und die weiter oben herunter geladene Datei auswählen und auf "load" klicken

Dashboard-icinga2-3.png

  • Unbedingt im Feld "Name" "icinga2-default" eintragen und bei InfluxDB "icinga2" auswählen und auf "Import" klicken

Dashboard-icinga2-4.png

Im Icinga2-Webinterface

Der folgende Vorgang muss für jeden einzellnen Graphen im Dashboard wiederholt werden!

  • Links auf "Configuration" und dort auf "Grafana Graphs"

Icingaweb2-grafana-1.png

  • Es müsste eine Liste der bereits vorhandenen Grafana Graphen erscheinen über der sich wie im unteren Screenshot der Button "Add Grafana Graph" befinden müsste

Icingaweb2-grafana-2.png

  • Das sich öffnende Formular wie unten ausfüllen und auf "Add Graph" klicken

Icingaweb2-grafana-3.png

Centos