Install Grafana on Ubuntu 20.04 - Step by Step Process ?

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, and so on.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Server Monitoring queries on Linux Systems.

In this context, we shall look into the process of Installing Grafana on Ubuntu OS. 


How to Install Grafana on Ubuntu ?

You can install Grafana via the following method:

  • Grafana Installation through APT repository.
  • Grafana Installation through .deb package.


1. Grafana Installation through APT repository

Here, 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.

i. 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.

ii. 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.

iii. 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

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

$ sudo apt update

v. 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.

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

$ grafana-server -v

The output will show the version of Grafana 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 an output which shows Grafana service is running without any errors.


2. Grafana Installation through .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.

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

$ sudo apt-get install -y adduser libfontconfig1

ii. 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.

iii. Now install the Grafana using this command:

$ sudo dpkg -i grafana_8.0.5_amd64.deb

To verify the installation, use the command below:

$ grafana-server -v

The output will verify the Grafana version 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.


How to Configure Firewall for Grafana Service ?

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


How to 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 Grafana Dashboard.


How to Uninstall Grafana from Ubuntu Linux System ?

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.


[Need help in Installing Open Source Software on Ubuntu Linux System ? We can help you. ]

This article covers how to install Grafana on Ubuntu OS using two methods: using the APT repository and the .deb package. Grafana is multi-platform open-source analytics and interactive visualization web application that integrates with complex data from sources like Prometheus, InfluxDB, Graphite, and ElasticSearch. It provides charts, graphs, and alerts for the web when connected to supported data sources. It is expandable through a plug-in system.


Features of Grafana:

  • Data Visualization: Allows for fast and flexible visualization with many options and settings.
  • Dynamic Dashboards: Provides the ability to create dynamic and reusable panels with templated variables.
  • Metrics Exploration: Explore your data with ad-hoc queries and dynamic drill-down by splitting the view and comparing different time ranges and sources.
  • Data Logs: Provides tremendous opportunities to use data metrics in a log with labels and filters saved, which can be studied, viewed, and broadcasted.
  • Extensive Alert Capabilities: Visually define alert rules for your most important metrics. Grafana will continuously evaluate and send notifications to systems such as Slack, PagerDuty, VictorOps, and OpsGenie.
  • Mixed Data Sources: Mix different data sources on the same graph and for each query.

Related Posts