Grafana » Cronologia » Versione 1
  Simone Piccardi, 26-06-2018 12:40 
  
| 1 | 1 | Simone Piccardi | h1. Installare e configurare Grafana | 
|---|---|---|---|
| 2 | |||
| 3 | Installare il pacchetto con prima aggiungendo una source list (ad esempio in @/etc/apt/sources.list.d/grafana.list@) come: | ||
| 4 | |||
| 5 | <pre> | ||
| 6 | deb https://packagecloud.io/grafana/stable/debian/ jessie main | ||
| 7 | </pre> | ||
| 8 | |||
| 9 | e poi eseguendo: | ||
| 10 | |||
| 11 | <pre> | ||
| 12 | apt-get install grafana | ||
| 13 | </pre> | ||
| 14 | |||
| 15 | verrà installato il programma, questo creerà le sue credenziali di accesso (il default è admin/admin) all'avvio, che deve essere eseguito esplicitamente, in particolare è necessario eseguire: | ||
| 16 | |||
| 17 | <pre> | ||
| 18 | systemctl daemon-reload | ||
| 19 | systemctl enable grafana-server | ||
| 20 | </pre> | ||
| 21 | |||
| 22 | per avviarlo: | ||
| 23 | |||
| 24 | <pre> | ||
| 25 | systemctl start grafana-server | ||
| 26 | </pre> | ||
| 27 | |||
| 28 | se si vogliono cambiare le credenziali prima di avviarlo, occorre modificare @/etc/grafana/grafana.ini@ cambiando le righe: | ||
| 29 | |||
| 30 | <pre> | ||
| 31 | # default admin user, created on startup | ||
| 32 | ;admin_user = admin | ||
| 33 | |||
| 34 | # default admin password, can be changed before first start of grafana, or in profile settings | ||
| 35 | ;admin_password = admin | ||
| 36 | </pre> | ||
| 37 | |||
| 38 | Inoltre conviene predisporre un reverse proxy, fare ascoltare grafana solo su localhost (il default è ovunque) e redirigere sullo stesso le connessioni usando un indirizzo pubblico gestito da un server web con gli opportuni virtual host, per questo occorre impostare: | ||
| 39 | |||
| 40 | <pre> | ||
| 41 | # The ip address to bind to, empty will bind to all interfaces | ||
| 42 | http_addr = 127.0.0.1 | ||
| 43 | </pre> | ||
| 44 | |||
| 45 | inoltre per avere un indirizzo corretto inviato verso l'esterno si dovrà impostare la URL con cui si accede al servizio con: | ||
| 46 | |||
| 47 | <pre> | ||
| 48 | # The full public facing url you use in browser, used for redirects and emails | ||
| 49 | # If you use reverse proxy and sub path specify full url (with sub path) | ||
| 50 | ;root_url = http://localhost:3000 | ||
| 51 | root_url = https://grafana.miosito.it | ||
| 52 | </pre> | ||
| 53 | |||
| 54 | |||
| 55 | Occorre poi configurare il reverse proxy, ad esempio con Nginx si può creare un virtual host sotto @/etc/nginx/sites-available/grafana@ con una configurazione del tipo: | ||
| 56 | |||
| 57 | <pre> | ||
| 58 | upstream grafana { | ||
| 59 | server 127.0.0.1:3000; | ||
| 60 | } | ||
| 61 | server { | ||
| 62 | listen 443 ssl; | ||
| 63 | server_name grafana.miosito.it; | ||
| 64 | root /var/www/html; | ||
| 65 | ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; | ||
| 66 | ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; | ||
| 67 |    location / { | ||
| 68 | proxy_pass http://grafana; | ||
| 69 | client_max_body_size 20m; | ||
| 70 | proxy_http_version 1.1; | ||
| 71 | proxy_pass_header Server; | ||
| 72 | proxy_set_header Host $http_host; | ||
| 73 | proxy_redirect off; | ||
| 74 | proxy_set_header X-Real-IP $remote_addr; | ||
| 75 | proxy_set_header X-Scheme $scheme; | ||
| 76 | proxy_set_header X-Forwarded-Proto $scheme; | ||
| 77 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | </pre> | ||
| 81 | |||
| 82 | e per usarlo creare in link simbolico verso lo stesso su @/etc/nginx/sites-enabled/grafana@ e riavviare Ngnix con @service nginx restart@. | ||
| 83 | |||
| 84 | Per avere un corretto funzionamento delle notifiche per posta elettronica (usate per inviare gli inviti agli utenti) deve essere configurata la sezione @[smtp]@ del file di configurazione, definendo: | ||
| 85 | |||
| 86 | <pre> | ||
| 87 | enabled = true | ||
| 88 | host = localhost:25 | ||
| 89 | from_address = admin@grafana.miosito.it | ||
| 90 | </pre> |