How to install Grafana 8 on Ubuntu 21.04

In this tutorial guide we are going to learn how to install Grafana 8 on Ubuntu 21.04 server. Grafana is a complete observability stack that allows you to monitor and analyze logs, metrics and traces.

Grafana allows you to query, visualize, alert on and understand your data insight. Grafana can create, explore and create beautiful dashboards that can be shared with your teams.

Related Contents

Grafana Components

  • Grafana Open source. This is an open source visualization and analytics software. It allows one to query, visualize, alert on and check for traces every where. It provides you with tools to turn your time series database to impactful graphs which are easy to interpret.
  • Grafana Loki. It is an open source set of components that can be composed into a fully featured logging stack.
  • Grafana Tembo. This is an open source easy to use and high volume distributed tracing backend

Why Grafana?

Grafana have been widely adopted by big companies due to the following reasons:

  • Grafana provides data for everyone. Grafana was built with a philosophy that data should be accessible to everyone. By providing data to everyone it provides a way that everyone can give opinion and recommendations of what should be done with regard to the datasets available to everyone.
  • Grafana unify your data, not databases. Grafana provides a way of unifying all your data wherever it exists and show them in a single dashboard.
  • Grafana provides for data flexibility and versatility. Grafana translates and transform any of your data into flexible and versatile dashboards. Grafana allows you to build dashboards specifically for you according to data available. You can create customized data according to your needs.
  • Grafana provides dashboards for everyone. Grafana provides you with an option to share your dashboard with every team, providing good decision making.

Grafana Features

Grafana has many features such as:

  • Dashboard templating. Dashboards allows users to build visualization graphs that is shareable with other groups. Dashboard is the most convenient way to create all the data pool that can be adhered easily.
  • Annotations. This feature allows you to mark graphs so that in case of a problem you know where to return to. This features helps a lot in case their error with your tabulations.
  • Kiosk mode and playlist. playlist is good for rolling coverage. Let’s say you want to display your contents on a bigger screen, you will use playlist to do that, it can play all what you have all the time required. Kiosk mode on the other hand lets you show the interface elements that is needed in view-mode only.
  • Alerting. Grafana alerting is the most important feature because it let you know when something went wrong. Think of database error, it will alert you on the severance of the error and what measures need to be taken care of.
  • Plugins. You can extend grafana functionalities with the help of plugins. Get interface with other products through plugins. This has made it possible for grafana to be widely used.

Installing Grafana on Ubuntu 21.04

1. Run system update

To install grafana, we have to run system updates, to do that use the following command:

$ sudo apt update

Afer the update is complete do run upgrade every package which might have been outdated. Use the following command to do so.

$ sudo apt upgrade -y

Install Software-properties-common

Software properties allow for easy management of PPA in the system. Use the following command to do so

$ sudo apt install software-properties-common
# sudo apt install software-properties-common
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
software-properties-common is already the newest version (0.99.10).
software-properties-common set to manually installed.
The following package was automatically installed and is no longer required:
  net-tools
Use 'sudo apt autoremove' to remove it.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

From the above we can see that software-properties-common is there by default on Ubuntu 21.04. Let’s go ahead and add GPG keys to Grafana.

2. Add Grafana to APT Repository

First we will need to add GPG keys to our APT sources keyring. Use the following command to accomplish this

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

You will get ok as the ouput. After this we can now add Grafana to the APT repository. Use the following command to do so

$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

Press Enter to continue with the installation.

# sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
Repository: 'deb https://packages.grafana.com/oss/deb stable main'
Description:
Archive for codename: stable components: main
More info: https://packages.grafana.com/oss/deb
Adding repository.
Press [ENTER] to continue or Ctrl-c to cancel.

It is now high time to install Grafana into our system. We have completed all the prerequisites, but first we need to update our system for the new changes to take effect.

$ sudo apt update

Then after the updates are complete install Grafana. Do this on the terminal

3. Install Grafana

$ sudo apt install grafana -y

-y instructs the system continue with installation without asking you to press enter in order to accept the installation.

4. Verify the installation

Use the following to verify your installation

$ grafana-server -v

Sample output

# grafana-server -v
Version 8.2.2 (commit: 6232fe07c0, branch: HEAD)

Start Grafana Service

Grafana needs to up and running for it to help us with monitoring, do start the service with the following command

$ sudo systemctl start grafana-server

Enable the service to run on start with the following command:

$ sudo systemctl enable grafana-server 

Sample Output

# 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/multi-user.target.wants/grafana-server.service → /lib/systemd/system/grafana-server.service.

You can verify the status of the Grafana with the following comand:

$ sudo systemctl status grafana-server

Sample Output

# sudo systemctl status grafana-server
● grafana-server.service - Grafana instance
     Loaded: loaded (/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-10-30 19:42:42 UTC; 2min 40s ago
       Docs: http://docs.grafana.org
   Main PID: 2000 (grafana-server)
      Tasks: 8 (limit: 2330)
     Memory: 26.9M
     CGroup: /system.slice/grafana-server.service
             └─2000 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/run/grafana/grafana-se>

Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Executing migration" lo>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="migrations completed" l>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Created default admin" >
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Created default organiz>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Starting plugin search">
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Registering plugin" log>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="External plugins direct>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Live Push Gateway initi>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="Writing PID file" logge>
Oct 30 19:42:44 ubuntu-21 grafana-server[2000]: t=2021-10-30T19:42:44+0000 lvl=info msg="HTTP Server Listen" log>

Installation is complete for now but where do we from here.. You are wondering what if i want to access the user interface of the Grafana. Don’t worry. Grafana can be accessed through port 3000 on the browser. But wait will it work really? Check it out first: Type your IP address:3000 on your browser to see what happens.

It shows an errror because we have not allowed the rules on the firewall. So let’s allow tcp access to the firewall. We can use the following command:

$ sudo ufw allow proto tcp from any to any port 3000
# sudo ufw allow proto tcp from any to any port 3000
Rules updated
Rules updated (v6)

when you type your address:3000 this time round Grafana interface will pop up as show below

Default username and password is admin, you will be created with the following Grafana interface.

Grafana Dashboard

Conclusion

Congratulations! You have installed Grafana monitoring tool and now you can start working on your project because you are covered with alerting tool. In case you find any problem always consult Grafana Documentation.

About Kipkoech Sang

I am a technology enthusiast who loves to share gained knowledge through offering daily tips as a way of empowering others. I am fan of Linux and all other things open source.
View all posts by Kipkoech Sang →

Leave a Reply

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