Grafana Installazione · 8 min read · Oct 28, 2025
Come installare il software di monitoraggio Grafana su Ubuntu 22.04

Grafana è un dashboard di metriche gratuito, open-source e ricco di funzionalità per la visualizzazione dei dati. È progettato per Graphite, Elasticsearch, OpenTSDB, Prometheus e InfluxDB per monitorare le metriche da un’interfaccia web. È multi-piattaforma e ha oltre 100 plugin per la raccolta, memorizzazione, visualizzazione e condivisione dei dati. Ti consente di creare avvisi e notifiche per i tuoi dati e facilitare la collaborazione con i tuoi compagni di squadra tramite funzionalità di condivisione.
Questo tutorial spiegherà come installare Grafana 8 su Ubuntu 22.04.
Requisiti
- Un server che esegue Ubuntu 22.04.
- Un nome di dominio valido puntato all’IP del tuo server.
- Una password di root configurata sul server.
Iniziare
Prima di iniziare, è consigliato aggiornare il sistema alla versione aggiornata. Puoi aggiornare tutti i pacchetti utilizzando il seguente comando:
apt-get update -y
apt-get upgrade -yUna volta che tutti i pacchetti sono stati aggiornati, installa le altre dipendenze necessarie utilizzando il seguente comando:
apt-get install gnupg2 curl wget git software-properties-common -yUna volta che tutti i pacchetti sono installati, puoi procedere al passaggio successivo.
Installa Grafana 8 su Ubuntu 22.04
Per impostazione predefinita, Grafana non è incluso nel repository predefinito di Ubuntu 22.04. Quindi dovrai aggiungere il repository di Grafana all’APT. Puoi aggiungerlo utilizzando il seguente comando:
curl https://packages.grafana.com/gpg.key | apt-key add -
add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"Una volta aggiunto il repository, aggiorna la cache del repository e installa Grafana utilizzando il seguente comando:
apt-get update -y
apt-get install grafana -yUna volta installato Grafana, avvia e abilita il servizio Grafana utilizzando il seguente comando:
systemctl start grafana-server
systemctl enable grafana-serverPuoi anche controllare lo stato del servizio Grafana con il seguente comando:
systemctl status grafana-serverOtterrai il seguente output:
? grafana-server.service - Grafana instance
Loaded: loaded (/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-06 09:33:06 UTC; 7s ago
Docs: http://docs.grafana.org
Main PID: 69737 (grafana-server)
Tasks: 9 (limit: 2242)
Memory: 37.1M
CPU: 1.580s
CGroup: /system.slice/grafana-server.service
??69737 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-server.pid --packaging=deb cfg>
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=secrets t=2022-08-06T09:33:08.517381147Z level=info msg="Envelope encryption state" >
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=query_data t=2022-08-06T09:33:08.527197639Z level=info msg="Query Service initializa>
Aug 06 09:33:08 ubuntu2204 grafana-server[69737]: logger=live.push_http t=2022-08-06T09:33:08.544920469Z level=info msg="Live Push Gateway in>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert t=2022-08-06T09:33:13.723313517Z level=warn msg="failed to delete old am con>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=infra.usagestats.collector t=2022-08-06T09:33:13.885398731Z level=info msg="register>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=server t=2022-08-06T09:33:13.886028388Z level=info msg="Writing PID file" path=/run/>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=http.server t=2022-08-06T09:33:13.900761945Z level=info msg="HTTP Server Listen" add>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert t=2022-08-06T09:33:13.901994976Z level=info msg="warming cache for startup"
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=ngalert.multiorg.alertmanager t=2022-08-06T09:33:13.902506414Z level=info msg="start>
Aug 06 09:33:13 ubuntu2204 grafana-server[69737]: logger=grafanaStorageLogger t=2022-08-06T09:33:13.926571246Z level=info msg="storage starti>
Per impostazione predefinita, Grafana ascolta sulla porta 3000. Puoi controllarlo con il seguente comando:
ss -antpl | grep 3000Otterrai il seguente output:
LISTEN 0 4096 *:3000 *:* users:(("grafana-server",pid=69737,fd=8)) Installa Nginx come Reverse Proxy per Grafana
Per impostazione predefinita, Grafana può essere accessibile tramite la porta 3000. Quindi, dovrai installare e configurare Nginx come reverse proxy per Grafana per accedervi tramite la porta 80. Prima, installa Nginx utilizzando il seguente comando:
apt-get install nginx -yUna volta installato Nginx, crea un file di configurazione del virtual host Nginx con il seguente comando:
nano /etc/nginx/conf.d/grafana.confAggiungi le seguenti righe:
server {
server_name grafana.example.com;
listen 80;
access_log /var/log/nginx/grafana.log;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}Salva e chiudi il file quando hai finito. Poi, verifica la sintassi di Nginx per eventuali errori con il seguente comando:
ginx -tSe tutto va bene, otterrai il seguente output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successfulSuccessivamente, riavvia Nginx per applicare le modifiche alla configurazione.
systemctl restart nginxPuoi anche controllare lo stato di Nginx con il seguente comando:
systemctl status nginxOtterrai il seguente output:
? nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-08-06 09:35:32 UTC; 4s ago
Docs: man:nginx(8)
Process: 70326 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 70327 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 70328 (nginx)
Tasks: 2 (limit: 2242)
Memory: 2.6M
CPU: 42ms
CGroup: /system.slice/nginx.service
??70328 "nginx: master process /usr/sbin/nginx -g daemon on; master_process on;"
??70329 "nginx: worker process" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
Aug 06 09:35:32 ubuntu2204 systemd[1]: Starting A high performance web server and a reverse proxy server...
Aug 06 09:35:32 ubuntu2204 systemd[1]: Started A high performance web server and a reverse proxy server.A questo punto, Nginx è installato e configurato come reverse proxy per Grafana. Puoi ora procedere al passaggio successivo.
Accedi al Dashboard di Grafana
Ora, apri il tuo browser web e accedi all’interfaccia web di Grafana utilizzando l’URL http://grafana.example.com. Sarai reindirizzato alla pagina di accesso di Grafana:

Fornisci il nome utente admin predefinito, la password come admin/admin e fai clic sul pulsante Accedi. Dovresti vedere la schermata di reimpostazione della password di Grafana:

Imposta la tua nuova password e fai clic sul pulsante Invia. Dovresti vedere il dashboard di Grafana nella schermata seguente:

Sicurezza di Grafana con Let’s Encrypt
Successivamente, dovrai installare il pacchetto client Certbot per installare e gestire il SSL di Let’s Encrypt.
Prima, installa Certbot con il seguente comando:
apt-get install certbot python3-certbot-nginx -yUna volta completata l’installazione, esegui il seguente comando per installare il SSL di Let’s Encrypt sul tuo sito web:
certbot --nginx -d grafana.example.comTi verrà chiesto di fornire un indirizzo email valido e accettare i termini di servizio come mostrato di seguito:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [email protected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for grafana.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/grafana.confSuccessivamente, scegli se reindirizzare o meno il traffico HTTP a HTTPS come mostrato di seguito:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2Digita 2 e premi Invio per completare l’installazione. Dovresti vedere il seguente output:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/grafana.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://grafana.example.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=grafana.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/grafana.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/grafana.example.com/privkey.pem
Your cert will expire on 2022-05-07. To obtain a new or tweaked
version of this certificate in the future, simply run certbot again
with the "certonly" option. To non-interactively renew *all* of
your certificates, run "certbot renew"
- Your account credentials have been saved in your Certbot
configuration directory at /etc/letsencrypt. You should make a
secure backup of this folder now. This configuration directory will
also contain certificates and private keys obtained by Certbot so
making regular backups of this folder is ideal.
- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
- We were unable to subscribe you the EFF mailing list because your
e-mail address appears to be invalid. You can try again later by
visiting https://act.eff.org.Conclusione
Congratulazioni! hai installato con successo Grafana 8 con Nginx come reverse proxy e SSL di Let’s Encrypt su Ubuntu 22.04. Puoi ora aggiungere le tue fonti di dati esterne a Grafana e iniziare a monitorarle dal dashboard di Grafana. Sentiti libero di chiedermi se hai domande.
Ricevi i nuovi post nella tua casella di posta.
Nessuno spam. Disiscriviti in qualsiasi momento.