Install Grafana on Ubuntu 20.04

Grafana is a cross-platform tool for data visualization, analytics, and monitoring. Data is retrieved from various data sources such as MySQL, Prometheus and then data is presented in the form of graphs, charts, etc. Grafana provides dashboard which is accessible to the user from a web browser. Grafana is an open-source project that released under the Apache License 2.0.

This tutorial explains how to install Grafana on Ubuntu 20.04.

Install Grafana

Run the following command to download GPG key:

sudo wget -qO /etc/apt/trusted.gpg.d/grafana.asc https://packages.grafana.com/gpg.key

Add the Grafana repository:

echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

Update the package lists with command:

sudo apt update

Install Grafana:

sudo apt install -y grafana

We can check Grafana version:

grafana-server -v

By default, Grafana service is not running. Service can be started with command:

sudo service grafana-server start

You can check if Grafana service is running by using the following command:

sudo service grafana-server status

We can also stop or restart the service:

sudo service grafana-server stop
sudo service grafana-server restart

To enable Grafana to start on boot, execute the following command:

sudo systemctl enable grafana-server

Testing Grafana

Open a browser and go to address http://<IP_ADDRESS>:3000, where <IP_ADDRESS> is IP address of your machine. Log in to the dashboard with the default username (admin) and password (admin).

Grafana dashboard on Ubuntu

Uninstall Grafana

If you want to completely remove Grafana and related dependencies, execute the following command:

sudo apt purge --autoremove -y grafana

When it finished, remove systemd service:

sudo service grafana-server stop
sudo systemctl disable grafana-server
sudo systemctl daemon-reload
sudo systemctl reset-failed

Remove GPG key and repository:

sudo rm -rf /etc/apt/trusted.gpg.d/grafana.asc
sudo rm -rf /etc/apt/sources.list.d/grafana.list

Remove Grafana user:

sudo deluser grafana

You can also remove the Grafana data, logs, and configuration:

sudo rm -rf /var/lib/grafana
sudo rm -rf /var/log/grafana
sudo rm -rf /etc/grafana
sudo rm -rf /run/grafana

Leave a Comment

Your email address will not be published. Required fields are marked *