Outils pour utilisateurs

Outils du site


services:grafana.chapril.org

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
services:grafana.chapril.org [2026/04/11 17:40] – supprimée - modification externe (Date inconnue) 127.0.0.1services:grafana.chapril.org [2026/04/11 17:40] (Version actuelle) – ↷ Page déplacée de admin:services:grafana.chapril.org à services:grafana.chapril.org pitchum
Ligne 1: Ligne 1:
 +====== Service grafana.chapril.org ======
 +
 +[[https://agir.april.org/issues/4439|Ticket n°4439]] sur Agir.
 +
 +Cette page présente l'installation de Grafana et la configuration du module d'intégration de graphiques de Grafana dans Icingaweb2.
 +
 +===== 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 :
 +<code bash>
 +cd /etc/nginx/sites-enabled/
 +cat grafana.chapril.org
 +</code>
 +<code nginx>
 +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;
 +    include /etc/nginx/force-ssl.conf;
 +}
 +
 +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;
 +    }
 +
 +}
 +</code>
 +
 +==== Installation et configuration de Grafana ====
 +
 +Sur la VM hébergeant Icingaweb2 : ''admin.cluster.chapril.org''.
 +
 +=== Installation ===
 +
 +Pour installer :
 +<code bash>
 +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"
 +apt update
 +apt install grafana 
 +</code>
 +
 +=== Configuration ===
 +
 +Dans ''/etc/grafana/grafana.ini'' décommenter le compte ''admin/password'' (mettre un mot de passe).
 +<code bash>
 +systemctl enable grafana-server.service
 +systemctl start grafana-server
 +</code>
 +
 +<note important>
 +Attendre l'initialisation initiale
 +</note>
 +
 +==== Intégration des données d'Icinga2 dans Grafana et des //graph// Grafana dans Icingaweb2 ====
 +
 +=== InfluxDB ===
 +
 +Installation d'InfluxDB :
 +<code bash>
 +apt install influxdb influxdb-client
 +</code>
 +
 +Configuration de la base InfluxDB : 
 +<code bash>
 +cd ~/
 +influx
 +</code>
 +<code>
 +Connected to http://localhost:8086 version 1.6.4
 +InfluxDB shell version: 1.6.4
 +</code>
 +<code sql>
 +CREATE DATABASE icinga2;
 +
 +CREATE USER icinga2 WITH PASSWORD '********';
 +GRANT ALL ON icinga2 TO icinga2
 +</code>
 +
 +Activation des modules icinga pour InfluxDB :
 +
 +<code bash>
 +icinga2 feature enable perfdata
 +
 +icinga2 feature enable influxdb
 +</code>
 +
 +Configuration du module Icingaweb2 d'InfluxDB, fichier ''/etc/icinga2/features-enabled/influxdb.conf''
 +<code nagios>
 +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$" 
 +    }
 +  }
 +}
 +</code>
 +
 +=== Intégration des données d'Icinga dans Grafana ===
 +
 +Se connecter sur l'interface Grafana pour ajouter un //datasource// avec l'utilisateur ''admin''.
 +
 +Ajouter un //datasource// InfluxDB avec les informations suivantes :
 +<code>
 +url: http://127.0.0.1:8086
 +Acces: Server
 +Database: icinga2
 +user: icinga2
 +password : *******
 +http method: GET
 +</code>
 +
 +Noter le nom du //datasource// (InfluxDB par défaut).
 +
 +Cliquer sur //Save & Test//.
 +
 +Générer un jeton //viewer// et garder la valeur pour la configuration du module ''grafana'' d'Icinga2.
 +
 +Intégrer dans Grafana le //dashboard// idoine via son ID (voir https://grafana.com/grafana/dashboards/1572?osource=grafana_getting_started).
 +
 +=== Intégration des graphiques Grafana dans Icingaweb2 ===
 +
 +Récupération du module Grafana pour Icingaweb2 :
 +
 +<code bash>
 +git clone https://github.com/Mikesch-mp/icingaweb2-module-grafana /usr/share/icingaweb2/modules/grafana
 +mkdir /etc/icingaweb2/modules/grafana
 +chown www-data:icingaweb2 /etc/icingaweb2/modules/grafana
 +</code>
 +
 +Configuration du module Grafana d'Icingaweb2, avec le //dashboarduid// et le nom du //datasource// notés précédemment, fichier ''/etc/icingaweb2/modules/grafana/config.ini'' :
 +<code 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" 
 +</code>
 +
 +Pour ne pas afficher de graphe vide, il suffit de désactiver les //perfdata// au niveau du service Icinga :
 +
 +<code ini>
 +enable_perfdata = false
 +</code>
 +
 +==== Configuration du 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''
 +<code 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                                                                                                                                                                                               
 +</code>
 +
 +Puis redémarrer le service :
 +<code bash>
 +systemctl restart grafana-server.service
 +</code>