How to Install Grafana on Ubuntu 22.04? (Step by Step Installation Guide)

Published on September 12, 2024, Updated on November 11, 2024

Grafana is a powerful open-source analytics and visualization tool designed for monitoring and creating interactive dashboards. It supports a wide range of data sources, enabling users to query and visualize data, metrics, and logs analysis effectively. 

Grafana is commonly used for real-time monitoring, such as tracking Kubernetes clusters, and it aids in gaining insights into system performance. 

Additionally, it allows users to set up alerts based on specific conditions, ensuring proactive issue management. 

This guide will show you how to install Grafana on Ubuntu 22.04, enabling you to leverage its capabilities for effective data monitoring and visualization.

What is Grafana Default Port?

Grafana default port is 3000. When you install and run Grafana, it is accessible via your web browser at http://localhost:3000 by default. As a Grafana administrator, you need to be familiar with configuration options and the Grafana CLI. This includes managing config files and environment variables to set ports, adjust logging, configure email settings, and enhance security.

Prerequisites

This Grafana installation guide will demonstrate how to install Grafana on Ubuntu 22.04. Before starting the installation, you should have these prerequisites:

  • An Ubuntu server running on your system or inside Virtualbox.
  • A non-root user should have sudo privileges.

How to Install Grafana on Ubuntu 22.04? (Grafana Installation Steps)

We will demonstrate in this grafana tutorial how to install Grafana on Ubuntu from the official APT repository. Follow these steps to install Grafana on Ubuntu:

Step 1: Update Apt Repository

First, ensure that your system's packages are up to date by running the following command in your terminal:

 

$ sudo apt update 

 

After that, execute the following command to upgrade all packages to the latest available version:

 

$ sudo apt upgrade

 

Step 2. Install Required Packages

Install the necessary packages for running Grafana on your Ubuntu system:

 

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

 

Step 3. Import Grafana GPG Key

Create the directory for the GPG key and import it:

 

$ sudo mkdir -p /etc/apt/keyrings/

 

The above command creates a directory to store the key. 

 

$ wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null

 

This command downloads converts, and saves the key in this directory for secure APT package management.

Step 4. Add Grafana Stable Repository

To add the stable repository for Grafana, use the following command:

 

$ echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list

 

After adding the Grafana repository to your system, you need to update the list of available packages to include the new Grafana repository:

 

$ sudo apt-get update

 

Step 5. Install Grafana on Ubuntu

To install the latest open-source version of Grafana, execute:

 

$ sudo apt install grafana

 

For the Enterprise version of Grafana, use the following command:

 

$ sudo apt install grafana-enterprise

 

Step 6. Enable and Start the Grafana Service

After completing the Grafana installation, you can check the version with:

 

$ sudo grafana-server -v

 

Then, start the Grafana service and set it to launch automatically on system reboot using these commands:

 

$ sudo systemctl start grafana-server

$ sudo systemctl enable grafana-server

 

You can check the running status of the Grafana server using this command:

 

$ sudo systemctl status grafana-server

 

Step 7 - Access the Grafana Web Interface

To access the Grafana web interface, open a web browser and navigate to http://your_server_IP:3000. You will see the Grafana login page. Use the default credentials:

  • Username: admin
  • Password: admin

You will be prompted to create a new password. Enter and confirm a secure password, then click "Submit." You will now have access to Grafana's dashboard.

How to Uninstall Grafana from Ubuntu 22.04?

If you need to uninstall Grafana, run the following commands:

 

$ sudo systemctl stop grafana-server

$ sudo apt remove grafana

Conclusion

In this guide, we explained how to install Grafana on Ubuntu 22.04. Grafana is a valuable tool for IT professionals and server administrators, enabling you to visualize, query, and set alerts for metrics and logs from various data sources. With Grafana now installed on your Ubuntu server, you can explore its features further. For more details, refer to the grafana tutorial with official documentation.

Host World provides a robust VPS and dedicated servers offer flexible hosting for deploying and scaling Grafana with hourly billing and 24/7 technical support.