Ubuntu

How to Install Grafana on Ubuntu 20.04

How to Install Grafana on Ubuntu 20.04

Grafana is a monitoring and visualization software. With the help of a Dashboard and graphs, you can visualize, query, and monitor your data over a period of time. It can connect with complex data sources like MySQL, ElasticSearch, Graphite, Prometheus, etc.

In today’s post, we will walk you through the steps for the installation of Grafana on Ubuntu OS. You can install Grafana on Ubuntu OS using different ways:

Here, we will cover:

  • Installation of Grafana using APT repository
  • Installation of Grafana using .deb package

Note: Both installation methods shown here have been tested on Ubuntu 20.04 LTS.

Installing Grafana Using APT repository

In the following procedure, we will install Grafana using the APT repository. Although, you can install Grafana using the Ubuntu official repository but it is not the latest version. To get the Grafana latest version, we can use Grafana’s official APT repository. Using this method, it will be easier for you to update Grafana using the apt-get update whenever a newer version is available. Let’s get started.

1. Add the software-properties-common package to your system. It will allow you to easily manage PPAs in your system:

$ sudo apt install software-properties-common

Now the installation will be started and if during installation, you are prompted with y/n, type y and press Enter.

2. Now, you will have to import the Grafana GPG key to the APT sources keyring. Run the command below to do so:

$ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

This command will download the Grafana GPG key and add it to the APT sources keyring.

3. Next, use the command below to add Grafana repository to your system’s list of sources:

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

4. After adding the Grafana repository, update the system’s list of sources using the command below:

$ sudo apt update

5. Now you can install Grafana as follows:

$ sudo apt install Grafana

Now the installation will be started and if during installation, you are prompted with y/n, type y and press Enter.

6. To verify the installation, use the command below:

$ grafana-server -v

The output below verifies that Grafana version 8.0.5 has been installed on your system.

After installation, you can start the Grafana service using the command below:

$ sudo systemctl start grafana-server

Use the command below to make the service start automatically upon boot:

$ sudo systemctl enable grafana-server

To verify if the Grafana service is running, use the command below:

$ sudo systemctl status grafana-server

You should see the below output which shows Grafana service is running without any errors.

Now the Grafana has been installed and ready to use.

Installing Grafana Using .deb package

Grafana is also available as a .deb package on the Grafana official website. However, remember you will have to manually update Grafana each time a newer version is released. In this method, we will download Grafana using the .deb package from the Grafana official Downloads page. As of July 2021, the latest version of Grafana available on the website is 8.0.5.

1. First, install some prerequisites using the command below:

$ sudo apt-get install -y adduser libfontconfig1

2. Now using the command below, download the .deb package of Grafana 8.0.5. To download any other version, visit Grafana official Downloads link and get the version you need.

$ wget https://dl.grafana.com/oss/release/grafana_8.0.5_amd64.deb

This command will download the Grafana version 8.0.5 to your Home directory.

3. Now install the Grafana using this command:

$ sudo dpkg -i grafana_8.0.5_amd64.deb

4. To verify the installation, use the command below:

$ grafana-server -v

The output below verifies that Grafana version 8.0.5 has been installed on your system.

After installation, you can start the Grafana service using the command below:

$ sudo systemctl start grafana-server

Use the command below to make the service start automatically upon boot:

$ sudo systemctl enable grafana-server

To verify if the Grafana service is running, use the command below:

$ sudo systemctl status grafana-server

You should see the below output which shows Grafana service is running without any errors.

Now the Grafana has been installed and ready to use.

Configure Firewall

If you need to access Grafana from the same system on which Grafana is installed, you can skip this step. However, if you need to access Grafana from another system on the local network, you will need to open port 3000 in your firewall.

Here is the command to allow port 3000 in the firewall:

$ sudo ufw allow 3000/tcp

Access Grafana

In order to access Grafana, open any web browser and navigate to your Grafana’s server IP address as follows:

http://ip-address:3000

This will open the login screen of Grafana. Login using the admin as your username and password.

Once you are logged in using the default credentials, it will ask you to set a new password for your admin account. Type a new password and confirm it. Then click Submit.

After this, you will see the following Grafana Dashboard.

Uninstall Grafana

If you ever need to uninstall Grafana, you can do this by running the command below:

$ sudo apt remove grafana

Whether you have installed Grafana using the APT repository or using the .deb package, this command works for both methods and will remove Grafana from your system.

In this post, we covered how to install Grafana on Ubuntu OS using two methods: using the APT repository and the .deb package. Using either of the methods discussed above, you can have the latest version of Grafana on your system. In the end, we also covered how to uninstall Grafana in case you need to do so.

Similar Posts