1. Install Grafana
Update the system packages.
$ sudo apt update
Install required system packages.
$ sudo apt-get install -y gnupg2 curl software-properties-common
Add Grafana GPG key.
$ curl https://packages.grafana.com/gpg.key | sudo apt-key add -
Install the Grafana repository.
$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
Update the system packages.
$ sudo apt update
Install Grafana
$ sudo apt -y install grafana
Start Grafana service.
$ sudo systemctl start grafana-server
Enable Grafana service to start on system boot.
$ sudo systemctl enable grafana-server
Check the service status.
$ sudo systemctl status grafana-server
By default, Grafana is accessible on port 3000. To use Grafana on port 80, you can run a reverse proxy to forward all traffic on port 3000 to port 80. To do this, you can follow the instructions in the next step. Otherwise, use port 3000 to access the Grafana web interface.
Install Nginx.
$ sudo apt install nginx -y
Start Nginx service.
$ sudo systemctl start nginx
Enable Nginx service to start on system boot.
$ sudo systemctl enable nginx
Check Nginx service status.
$ sudo systemctl status nginx
Unlink the default configuration file.
$ sudo unlink /etc/nginx/sites-enabled/default
Create a new configuration file.
$ sudo nano /etc/nginx/sites-available/grafana.conf
Add the following code in the new file, save and close the file:
server {
listen 80;
location / {
proxy_pass http://localhost:3000;
}
}
Link and activate the new configuration file.
$ sudo ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/grafana.conf
Test the configuration file.
$ sudo service nginx configtest
Restart Nginx service.
$ sudo systemctl restart nginx
3. Access Grafana Dashboard
To access the Grafana Web Interface without reverse proxy, go to your browser and visit http://Server_IP:3000/
. For example:
http://192.0.2.10:3000/
To access the Grafana Web Interface over the reverse proxy, go to your browser and visit http://Server_IP/
. For example:
http://192.0.2.10/
Source: Install Grafana on Ubuntu 20.04 – Vultr.com