A Comprehensive Guide To Install Grafana on Ubuntu 24.04

Posted on

A Comprehensive Guide To Install Grafana on Ubuntu 24.04

This guide intends to teach you to Install Grafana on Ubuntu 24.04. Grafana is a widely used open-source platform for analytics and monitoring, enabling users to visualize and analyze data from multiple sources. Its interactive and customizable dashboards make it an essential tool for system administrators, developers, and IT professionals.

In this guide, you will learn to install the Grafana OSS version which is free to use. Grafana OSS provides all the core features to create interactive and dynamic dashboards that visualize data from multiple sources.

Now follow the steps below to install Grafana on Ubuntu 24.04 from the Orcacore team.

Easily Install And Access Grafana on Ubuntu 24.04

To install Grafana, you must log in to your server as a non-root user with sudo privileges. Also, you need to set up a basic firewall with UFW. For this purpose, you can check Basic UFW Firewall Configuration on Ubuntu 24.04.

Then, follow the steps below to complete this guide.

Step 1. Install Grafana on Ubuntu 24.04 with Deb Package

In this guide, we install Grafana by using the Deb binary package. You must visit the Grafana Downloads page, select the latest version available, and choose the OSS edition in this case.

First, run the system update and upgrade with the command below:

sudo apt update && sudo apt upgrade -y

At the current time, the latest OSS version is version 11.0, to download it, you can use the following commands:

# sudo apt-get install -y adduser libfontconfig1 musl
# wget https://dl.grafana.com/oss/release/grafana_11.0.0_amd64.deb

Once your download is completed, install Grafana on Ubuntu 24.04 with the following command:

sudo dpkg -i grafana_11.0.0_amd64.deb

Then, you can proceed to the next step to enable and start your Grafana server on Ubuntu 24.04.

Step 2. Start and Enable Grafana on Ubuntu 24.04

Once your installation is completed, you must reload the systemd unit configuration files with the following command:

sudo systemctl daemon-reload

Next, start and enable Grafana by using the following commands:

# sudo systemctl enable grafana-server
# sudo systemctl start grafana-server

Now you can verify that Grafana is active and running on Ubuntu 24.04 with the following command:

sudo systemctl status grafana-server

In your output, you should see:

Start and Enable Grafana on Ubuntu 24.04

Step 3. Access Grafana Dashboard

As you may know, the default port of Grafana is 3000. You can verify it by using the following command:

sudo ss -altnp | grep grafana

At this point, you can access your Grafana dashboard by typing localhost in your web browser followed by 3000:

http://localhost:3000

Note: For external access, you must allow port 3000 through your UFW firewall with the commands below:

# sudo ufw allow 3000/tcp
# sudo ufw reload

Then, you can access your Grafana dashboard by using the below URL:

http://server-ip:3000

Once you access the Grafana UI, you need to enter admin for both username and password. Then, change the password and click submit.

Now you will see your Grafanona dashboard on Ubuntu 24.04.

Let’s see how you can create your first dashboard on Grafana.

Step 4. Create your Grafana First Dashboard

To create your first dashboard, click Dashboards in the left-side menu. Then, click New and select New Dashboard from the dropdown menu. Next, click on + Add visualization. From the data source, click — Grafana —.

This configures your query and generates the Random Walk dashboard. Click the Refresh dashboard icon to query the data source. And click Save to save the dashboard. Enter a name and click save.

That’s it, you have created your first dashboard with Grafana.

The process of creating a new dashboard looks like this:

For more information, you can visit the Grafana Documentation page.

Conclusion

Grafana OSS is a powerful data visualization and monitoring tool. It offers a wide range of features in its open-source version. It excels in integrating diverse data sources, creating customizable dashboards, and providing alerting capabilities. Whether you are managing IT infrastructure, monitoring application performance, or analyzing business metrics, Grafana OSS facilitates informed decision-making with real-time data.

At this point, you have learned to Install Grafana on Ubuntu 24.04 by using the Deb binary package and access your dashboard, and then, create your first dashboard on Grafana. Installing Grafana on Ubuntu 24.04 is now easier than ever.

Hope you enjoy it. Also, you may like to read the following articles:

Monitor Ubuntu Server with Glances Remotely

Installing bmon on Ubuntu 22.04

Network Monitoring in Debian With Sniffnet Tool

CheckMK Setup on AlmaLinux 9

Rocky Linux 9 Network Monitoring Using Nagios

Alternative Installation Methods for Grafana on Ubuntu 24.04

While the .deb package installation method outlined above is straightforward, there are other ways to install Grafana on Ubuntu 24.04. Here are two alternative methods: using APT repository and using Docker.

Method 1: Installing Grafana using the APT Repository

This method involves adding the official Grafana APT repository to your system and installing Grafana using the apt package manager. This ensures you receive updates automatically when they are released.

Steps:

  1. Add the Grafana APT repository:

    First, you need to add the Grafana repository key to your system. This ensures that packages downloaded from the repository are trusted.

    sudo apt-get update
    sudo apt-get install -y apt-transport-https software-properties-common wget
    wget -q -O - https://apt.grafana.com/gpg.key | sudo apt-key add -

    Then, add the Grafana repository to your APT sources:

    echo "deb https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list
  2. Update the package list and install Grafana:

    Update your package list to include the newly added repository, and then install Grafana:

    sudo apt-get update
    sudo apt-get install -y grafana
  3. Start and Enable Grafana:

    As with the .deb package installation, start and enable the Grafana service:

    sudo systemctl daemon-reload
    sudo systemctl enable grafana-server
    sudo systemctl start grafana-server
  4. Verify Grafana is Running:

    Check the status of the Grafana service to ensure it is running correctly:

    sudo systemctl status grafana-server

This method ensures that you receive updates to Grafana automatically through the standard Ubuntu package management system.

Method 2: Installing Grafana using Docker

Docker provides a containerized environment for running applications. Installing Grafana via Docker simplifies deployment and management, especially in environments where containerization is already in use.

Prerequisites:

  • Docker must be installed on your Ubuntu 24.04 system. If not, install it using:

    sudo apt update
    sudo apt install docker.io
    sudo systemctl start docker
    sudo systemctl enable docker

Steps:

  1. Pull the Grafana Docker image:

    Pull the latest Grafana image from Docker Hub:

    sudo docker pull grafana/grafana
  2. Run the Grafana Docker container:

    Run the Grafana container with port 3000 mapped to your host system and persist the data volume:

    sudo docker run -d --name=grafana -p 3000:3000 -v grafana_data:/var/lib/grafana grafana/grafana

    Explanation of the options:

    • -d: Runs the container in detached mode (in the background).
    • --name=grafana: Assigns the name "grafana" to the container.
    • -p 3000:3000: Maps port 3000 on the host to port 3000 in the container.
    • -v grafana_data:/var/lib/grafana: Creates a named volume grafana_data to persist Grafana data. This ensures that your dashboards and settings are preserved even if the container is stopped or removed.
    • grafana/grafana: Specifies the Docker image to use.
  3. Access Grafana:

    Once the container is running, you can access Grafana by navigating to http://localhost:3000 in your web browser.

  4. Managing the Docker Container:

    You can manage the Grafana container using standard Docker commands:

    • Stop the container: sudo docker stop grafana
    • Start the container: sudo docker start grafana
    • Restart the container: sudo docker restart grafana
    • View container logs: sudo docker logs grafana

Using Docker offers a consistent and isolated environment for running Grafana, simplifying deployment and updates. It’s particularly useful for managing complex infrastructure or when deploying Grafana in a microservices architecture.

These alternative methods provide flexibility in how you choose to deploy and manage Grafana on Ubuntu 24.04, depending on your specific needs and environment. Installing Grafana on Ubuntu 24.04 is achievable through several methods.