Ceci est une ancienne révision du document !
Table des matières
Service grafana.chapril.org
Ticket sur agir https://agir.april.org/issues/4439
Installation
Déploiement du domaine grafana.chapril.org
Suivre la procédure d'ajout d'un domaine.
Déploiement du domaine sur la vm bastion
Sur la vm bastion, configurer un nouveau site :
=(^-^)=root@bastion:/etc/nginx/sites-enabled# cat grafana.chapril.org server { listen 80; listen [::]:80; server_name grafana.chapril.org; access_log /var/log/nginx/grafana.chapril.org/grafana.chapril.org-access.log; error_log /var/log/nginx/grafana.chapril.org/grafana.chapril.org-error.log; include /etc/nginx/acme-challenge; include /etc/nginx/sexy-chapril; rewrite ^(.*)$ https://$host$request_uri permanent; } server { listen 443 ssl; listen [::]:443 ssl; server_name grafana.chapril.org; access_log /var/log/nginx/grafana.chapril.org/grafana.chapril.org-access.log; error_log /var/log/nginx/grafana.chapril.org/grafana.chapril.org-error.log; ssl_certificate /var/lib/dehydrated/certs/grafana.chapril.org/fullchain.pem; ssl_certificate_key /var/lib/dehydrated/certs/grafana.chapril.org/privkey.pem; include /etc/nginx/acme-challenge; include /etc/nginx/sexy-chapril; location / { proxy_pass http://admin.cluster.chapril.org:3000; } }
Installation d'influxdb, du plugin icinga et grafana
Sur la vm hébergeant icinga 2 (admin.cluster.chapril.org) :
Installation des modules, de la base et de grafana :
git clone https://github.com/Mikesch-mp/icingaweb2-module-grafana /usr/share/icingaweb2/modules/grafana apt install influxdb influxdb-client apt-get install -y apt-transport-https apt-get install -y software-properties-common wget wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add - sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
Configuration de la base influxdb :
(April) root@admin:~# influx Connected to http://localhost:8086 version 1.6.4 InfluxDB shell version: 1.6.4 > CREATE DATABASE icinga2; CREATE USER icinga2 WITH PASSWORD '********'; GRANT ALL ON icinga2 TO icinga2 icinga2 feature enable perfdata icinga2 feature enable influxdb
Configuration du module icinga2 d'influxdb :
vim /etc/icinga2/features-enabled/influxdb.conf library "perfdata" object InfluxdbWriter "influxdb" { host = "127.1" port = 8086 database = "icinga2" username = "icinga2" password = "*****************" 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$" } } }
Configurer grafana :
/etc/grafana/grafana.ini : décommenter compte admin/password (mettre un mot de passe) systemctl enable grafana-server.service systemctl start grafana-server
Se connecter sur l'interface grafana pour ajouter un datasource avec l'utilisateur admin.
Ajouter un datasource influxdb avec les informations suivantes :
url: http://127.0.0.1:8086 Acces: Server Database: icinga2 user: icinga2 password : ******* http method: GET
Noter le nom du datasource (InfluxDB par défaut)
Cliquer sur “Save & Test”
Générer un token “viewer” et garder la valeur pour la configuration du module grafana d'icinga2.
Intégrer le dashboard https://grafana.com/grafana/dashboards/1572?osource=grafana_getting_started
Configuration du module grafana, avec le dashboarduid noté précédement :
mkdir /etc/icingaweb2/modules/grafana chown www-data:icingaweb2 /etc/icingaweb2/modules/grafana vim /etc/icingaweb2/modules/grafana/config.ini [grafana] version = "1" host = "127.1:3000" protocol = "http" timerangeAll = "1w/w" defaultdashboard = "icinga2-default" defaultdashboarduid = "j9hX7K6Wz" defaultdashboardpanelid = "1" defaultorgid = "1" shadows = "0" theme = "light" datasource = "influxdb" accessmode = "proxy" height = "280" width = "640" enableLink = "yes" debug = "0" authentication = "token" apitoken = "************" usepublic = "yes" publichost = "grafana.april.org" publicprotocol = "https"
Pour ne pas afficher de graphe vide, il suffit de désactiver les perfdata au niveau du service icinga :
enable_perfdata = false
Configurer le courriel
La configuration du courriel est importante dans l'invitation de membre dans Grafana (voir https://agir.april.org/issues/5163).
Éditer /etc/grafana/grafana.ini :
#################################### SMTP / Emailing ########################## [smtp] enabled = true host = localhost:25 ;user = # If the password contains # or ; you have to wrap it with trippel quotes. Ex """#password;""" ;password = ;cert_file = ;key_file = skip_verify = true from_address = admins-auto@chapril.org ;from_name = Grafana [emails] welcome_email_on_sign_up = true
Puis redémarrer le service :
systemctl restart grafana-server.service