How to Install and Set Up Grafana on Ubuntu

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

It allows exploring the data through queries, visualizing the data using numerous visualization components like charts, histograms, heatmaps, etc., and setting up alerts and notifications. Grafana supports a range of data sources such as Prometheus, Graphite, Elasticsearch, PostgreSQL and many others. How to set up Grafana on Ubuntu.


1. Install Grafana from the official repository

You can install Grafana on Ubuntu using the official repository and the APT package manager. To begin 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 Grafana’s 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 the Enterprise Edition

Issue the following command to add the Grafana GPG key and 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

After the update is complete, issue the following command to install the Grafana Enterprise Edition:

sudo apt install grafana-enterprise

For the OSS edition

Issue the following command to add the Grafana GPG key and 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 the DEB package

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

Downloads: 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 the Enterprise Edition

wget https:

For the 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 binary TAR.GZ file available on the official website. You can either download the binary from the website manually or use the following commands.

Downloads: Grafana

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

For the Enterprise Edition

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

For the OSS edition

wget https:

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

sudo tar -zxvf grafana-*.tar.gz

The above command extracts the contents of the archive into a directory with the same base name as the downloaded archive version. You can find this new directory under your current directory.

How to manage Grafana services on Ubuntu

Grafana server does not start automatically after installation. Based on the installation methods you use, you can either start the service manually using systemctl or by running the binary.

If you installed Grafana from the official repository or with 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 Grafana’s 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:

Change 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 Ctrl + C to stop it.

How to access the Grafana web interface

Grafana listens on the standard HTTP port 3000. For external access you 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 your system’s IP address and port 3000.

http:

The following Grafana login screen will open. Sign in using the following default credentials:

E-mail address or username: Administrator

Password: Administrator

Then you will be prompted to set a new password for your Grafana login. After setting the new password, you will be taken to the Grafana dashboard.

How to set up Grafana on Ubuntu

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

Add a data source in Grafana

Follow these steps to add a data source in Grafana:

  1. In the left sidebar of the Grafana dashboard, click the settings Symbol.
  2. click Add data source and then select the data source type from the list of all supported data sources.
  3. Fill in the required parameters (URL or host details, authentication or authorization details, etc.) to configure the data source.
  4. When you’re done, click Save & test. If you see one Database connection OK message, it means everything went well and your data source is connected.

Create a new dashboard

Follow these steps to create a new dashboard in Grafana:

  1. Hover over the dashboards icon in the left sidebar and click on it New dashboard.
  2. click Add a new panel and under the inquiry tab, select Data Source. Next to Data Sourcethere will be Query Options. Configure the necessary settings for the query. In the right sidebar, select the visualization type and name the panel.
  3. When you’re done, click Save on computer Name the dashboard in the top right corner and save it. After that, Grafana will automatically bring 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 with:

sudo apt purge grafana

If you installed Grafana with the binary, 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 on Ubuntu with customizable dashboards

With the help of customizable dashboards in Grafana, you can visualize large and complex data from different data sources. Given the different methods to install Grafana, you can choose any method as you like.

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

Leave a Reply

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