How to install and configure Grafana on Ubuntu

Data visualization tools make it easy to identify useful information and draw conclusions from large and complicated data sets. Grafana is one of the popular and open source interactive data visualization tools that allows you to analyze and visualize your data from all sources in a unified dashboard.

It allows you to explore the data through queries, visualize the data using a multitude of visualization components such as graphs, histograms, heat maps, etc., and configure alerts and notifications. Grafana supports various data sources including Prometheus, Graphite, Elasticsearch, PostgreSQL, and many others. Here’s how to set up Grafana on Ubuntu.


1. Install Grafana from the official repository

You can install Grafana on Ubuntu using its official repository and the APT package manager. To start the installation, open the terminal and use the following command to install some prerequisites:

sudo apt install -y apt-transport-https software-properties-common

Then download the Grafana GPG key:

wget -q -O /usr/share/keyrings/grafana.key https:

After installing the prerequisites and downloading the GPG key, add the repository and install Grafana.

For enterprise edition

Run the following command to add the GPG key and Grafana repository to your system’s APT sources:

echo deb [signed-by=/usr/share/keyrings/grafana.key] https:

Then update the repository index:

sudo apt update

Once the upgrade is complete, issue the following command to install the Grafana Enterprise edition:

sudo apt install grafana-enterprise

For OSS edition

Run the following command to add the GPG key and Grafana repository to your system’s APT sources:

echo deb [signed-by=/usr/share/keyrings/grafana.key] https:

Next, update the repository index by running:

sudo apt-get update

Then issue the following command to install the Grafana OSS edition:

sudo apt-get install grafana 

2. Install Grafana on Ubuntu using DEB package

Alternatively, you can also install Grafana by installing the DEB package available on the official website using dpkg. You can manually download the package from the website or use the commands mentioned below.

Discharge: Grafana

To start the installation, open the terminal and download the Grafana Enterprise or OSS edition depending on what you want to install on your system.

For enterprise edition

wget https:

For OSS edition

wget https:

Then issue the following command to install the Grafana DEB package:

sudo dpkg -i grafana*_amd64.deb

3. Install Grafana on Ubuntu using binaries

You can also install Grafana using the TAR.GZ binary file available on the official website. You can manually download the binary file from the website or use the commands below.

Discharge: Grafana

To begin the installation, open the terminal and use the following commands to download the TAR.GZ file.

For enterprise edition

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.1.5.linux-amd64.tar.gz

For OSS edition

wget https:

Now extract the TAR.GZ file using the following command:

sudo tar -zxvf grafana-*.tar.gz

The above command will extract the contents of the archive to a directory with the same base name as the version of the archive you downloaded. You can find this new directory in your current directory.

How to manage Grafana services in Ubuntu

Grafana server does not start automatically after installation. Depending on the installation methods you used, you can manually start your service using systemctl or by running the binary.

If you installed Grafana from the official repository or using the DEB package, use the following systemd commands to manage the Grafana server:

To start the Grafana service, use:

sudo systemctl daemon-reload
sudo systemctl start grafana-server

To check the status of the service, use:

sudo systemctl status grafana-server

To ensure that the Grafana service starts automatically on boot, use:

sudo systemctl enable grafana-server.service

If you installed Grafana using the TAR.GZ file, use the following commands to manage the Grafana server:

Go to the Grafana directory using the cd command:

cd /usr/local/Grafana

Now run the binary to start the Grafana server.

./bin/grafana-server web

Use Control + C to stop it

How to access the Grafana web interface

Grafana listens to the default HTTP port 3000. For external access, you will need to open this port in the firewall with the following command:

sudo ufw allow 3000/tcp

To access Grafana, open any browser and navigate to the IP address and port 3000 of your system.

http:

The following Grafana login screen will open. Login with the following default credentials:

E-mail or username: management

Key code: management

It will then ask you to set a new password for your Grafana login. After setting the new password, you will be redirected to the Grafana control panel.

How to configure Grafana on Ubuntu

Follow the steps below to configure Grafana by adding a data source and creating a new dashboard.

Add a data source in Grafana

To add a data source in Grafana, follow the steps below:

  1. In the left sidebar of the Grafana dashboard, click the Settings icon.
  2. Click Add data source and then choose the data source type from the list of all supported data sources.
  3. Fill in the necessary parameters (URL or host details, authentication or authorization details, etc.) to configure the data source.
  4. Once done, click save and test. if you see a Successful database connection message, it means everything went well and your data source is connected.

Create a new board

To create a new board in Grafana, follow the steps below:

  1. Hover over the boards icon in the left sidebar and click new board.
  2. Click Add a new dashboard and under the Query tab, select Data source. Beside Data sourceThere will be query options. Configure the necessary settings for the query. In the right sidebar, select the type of visualization and give the dashboard a name.
  3. Once done, click Save money in the upper right corner, give the board a name and save it. After that, Grafana will automatically take you back to the dashboard.

How to uninstall Grafana from Ubuntu

Depending on how you installed Grafana, there are different ways to uninstall it. If you installed Grafana from the official APT repository or via the DEB package, you can uninstall it using:

sudo apt purge grafana

If you installed Grafana using the binary file, you can uninstall it by removing both the Grafana directory and the TAR.GZ file:

sudo rm -r grafana-*tar.gz grafana-*

Visualize your data in Ubuntu with customizable dashboards

With the help of customizable dashboards in Grafana, you can visualize large and complex data from various data sources. Given the various Grafana installation methods, you can choose any method according to your convenience.

If you don’t want to install and configure Grafana on your system, there are other data visualization methods you can use instead.

Leave a Comment