Outils pour utilisateurs

Outils du site


admin:services:grafana.chapril.org

Service grafana.chapril.org

À reformater et compléter !

Extrait du ticket https://agir.april.org/issues/4439 :

Notes d'installation :

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" 

(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

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$" 
    }
  }
}

mkdir /etc/icingaweb2/modules/grafana

/etc/grafana/grafana.ini : décommenter compte admin/password (mettre un mot de passe)
systemctl enable grafana-server.service
systemctl start grafana-server

*attendre l'initialisation initiale*

ajouter la conf nginx sur bastion

server {
    listen 80;

    server_name grafana.april.org;

    access_log /var/log/nginx/grafana.april.org/grafana.april.org.access_log;
    error_log /var/log/nginx/grafana.april.org/grafana.april.org.error_log;

    include /etc/nginx/custom_50x;
    include /etc/nginx/deny_.git;
    include /etc/nginx/force-ssl.conf;
}

server {
    listen 443;
    ssl on;

    server_name grafana.april.org;

    access_log /var/log/nginx/grafana.april.org/grafana.april.org.access_log;
    error_log /var/log/nginx/grafana.april.org/grafana.april.org.error_log;

    include /etc/nginx/custom_50x;
    include /etc/nginx/deny_.git;

    location / {
        proxy_pass http://172.16.0.2:3000;
    }
}

ajouter le cname grafana dans la conf dns

se connecter sur l'interface grafana pour ajouter un datasource
se connecter en admin
ajouter un datasource influxdb

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)

Save & Test

Générer un token "viewer" et garder la valeur pour la conf du module grafana d'icinga2
Intégrer le dashboard 
https://grafana.com/grafana/dashboards/1572?osource=grafana_getting_started

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
admin/services/grafana.chapril.org.txt · Dernière modification: 2021/02/03 01:08 par cpm