How to Install Grafana 8 on Ubuntu 20.04

Grafana is a tool for monitoring, analysis, and visualization of real-time system data. From a series of data collected, we will obtain a graphical panorama of the situation of a company or organization. It generates graphs and dashboards from a time-series database (Graphite, InfluxDB, or OpenTSDB). It also allows you to share them as snapshots with other users.

In this tutorial, we learn how to Install Grafana 8 on Ubuntu 20.04.


  • A Ubuntu 20.04 Server
  • A user with sudo proviledges
  • Miminum of 255 MB of RAM
  • Minimum of 01 CPU
  • A supported database (MySQL, PostgreSQL, SQLite)
  • A compatible browser with javascript enabled
  • Port 3000 opened (if you don't use a reverse proxy)

Step 1: Install Grafana on Ubuntu

Grafana is not present in the default repositories of Ubuntu. We will add the official repository of Grafana for the installation. This ensures you have the latest version of it.

Run the following commands to add the Grafana repository:

$ sudo wget -q -O - | sudo apt-key add -
echo "deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

Install the other necessary packages

$ sudo apt install -y apt-transport-https software-properties-common wget

Update the cache of the repositories

$ sudo apt update

Now you can install Grafana with the APT command

$ sudo apt install grafana

You can check the version installed for more information

$ grafana-server -v
Version 8.2.3 (commit: fb85ed6912, branch: HEAD)

The output shows Grafana version 8.2 is installed.

Now enable the service on startup so that if the server reboot, it will also start automatically

$ sudo systemctl enable grafana-server
Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable grafana-server
Created symlink /etc/systemd/system/ → /lib/systemd/system/grafana-server.service.

You need to start the service for Grafana to work properly

$ sudo systemctl start grafana-server

Step 2: Nginx Reverse Proxy for Grafana

As we would like to access it through a domain name (or sub-domain), we will use a reverse proxy that will redirect the communication to Grafana on the server. So, we are going to install Nginx and add the certificate to handle all the external requests for Grafana.

Grafana normally runs on port 3000. It means that you need to open the port on the firewall and access it by IP address and port.

In our configuration, we will use Nginx as the reverse proxy to listen to the request on port 80/443

$ sudo apt install nginx

As we need to secure the communications, we will copy the certificate

$ sudo cp /etc/nginx/certs/

Then copy the key of the certificate

$ sudo cp /etc/nginx/certs/

As it's our first configuration, we need to deactivate the default configuration to avoid any possible conflict

$ sudo rm /etc/nginx/sites-enabled/default

It's time to set the configuration file for Grafana. You need to properly indicate where your certificate and key files are located. Also, by default Nginx will redirect all the traffic on port 80 to the secure channel on port 443

$ sudo vim /etc/nginx/sites-available/jenkins.conf
Server {
        listen 80 ;
        access_log /var/log/nginx/grafana.log;
        return 301 https://$host$request_uri;
server {
        listen 443 ssl http2 ;
        access_log /var/log/nginx/grafana.log;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
        ssl_prefer_server_ciphers on;
        ssl_session_timeout 5m;
        ssl_certificate /etc/nginx/certs/;
        ssl_certificate_key /etc/nginx/certs/;
        add_header Strict-Transport-Security "max-age=31536000";

        location / {
                proxy_pass http://localhost:3000;
                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;

Now we need to activate the configuration by creating a soft link of the configuration file in the folder /etc/nginx/site-enabled.

$ sudo ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/grafana.conf

You can check if the configuration of Nginx is good

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Then we need to restart the Nginx service to consider all the modifications

$ sudo systemctl restart nginx

Step 3: Access Grafana

Now that the installation and the configurations of Grafana are finished, we can access it. To do so, you need to open your browser and enter the URL of your Grafana server

The default username and password are admin. After that, you will be prompted to change the default password.

This will let you access directly to your dashboard

Now you can start working on your Grafana and set up everything. You can have a look at the official documentation if you need some guides for your configuration.


In this tutorial, we learned how to install Grafana on Ubuntu 20.04. Thanks for reading, please leave your feedback and suggestions in the comment section.

Leave a Comment