Learn how to install and configure Grafana and Prometheus on Ubuntu 22.04 LTS

​In this guide, you will learn how to install Grafana and Prometheus on Ubuntu 22.04. Grafana is an open-source data visualization and monitoring tool that integrates with various data sources, including Prometheus. Prometheus is an open-source time series database that is commonly used for monitoring and alerting purposes.


In order to complete this tutorial, the following is a list of items that may be needed to complete this tutorial successfully:
1) 2 physical servers, 2 virtual machines, or 2 cloud-hosted VPS subscriptions
2) A fully qualified domain name point to the public IP address of the Ubuntu 22.04 server
3) Grafana and Prometheus dependencies and binaries
4) An SSH client such as Putty or the built-in terminal app for MacOS / Linux Desktop
5) A web browser such as Google Chrome, Internet Explorer, Safari, Firefox


The following is an overview of the steps covered in this tutorial:
1) Add the package repository and install Grafana
2) Install and configure the NGINX web server 
3) Download, install, and configure Prometheus
4) Set up the node_exporter, add node_exporter to Prometheus
5) Integrate Prometheus with Grafana and set up dashboard monitoring

On Server 1

Step 1: Add the package repository and install Grafana

The first step in completing this setup is to install system dependencies for Graphana, Add the GPG key as well as the Graphana repository. Run the following command to install dependencies:

On the confirmation prompt, enter Y and press Enter.

When the dependencies installation is complete, run the following command to the GPG key for Grafana. The GPG key ensures secure communication when downloading Grafana and also ensures that the Graphana package that you download is authentic

Next, run the commands shown below to add the Grafana repository to the Ubuntu server

Now that you have installed system dependencies, and added the GPG keys as well as the repository, you can now install Grafana. Run the commands below to start the installation

On the confirmation prompt, enter Y and press Enter.

When the installation process is complete, use systemctl to start Grafana and set it to start automatically at system boot

It is important to check the status of the Grafana service especially just after installing it. Run the command below to check the status. The command should indicate that grafana-server.service is active (running)
The final step is to edit the /etc/grafana/grafana.ini configuration file. Open the file by running the command:

Scroll down to the [server] section and configure the following:

1) http_addr = localhost
2) http_port = 3000
3) domain = (this is the publicly facing domain name that you use to open grafana from a web browser)

To save changes, press CONTROL + O, press ENTER and press CONTROL + X to exit the file. Restart the grafana service so that the changes made to the grafana.ini configuration file take effect

Step 2: Install and configure NGINX

In step 2, download NGINX web server and configure it to operate as a reverse proxy server for Grafana. Run the command shown below to install NGINX:

Proceed to create a virtual host configuration file that will instruct NGINX how to handle HTTP traffic for Grafana

Copy and paste into the file the configuration below. The configuration creates a reverse proxy on port 3000 such that if a user enters in the browser address bar, the traffic will redirect to Ensure to replace with the domain that is pointing to the public IP address of the Ubuntu server.

To save the file, press ctrl + 0, press enter to confirm and press ctrl + x to exit the file. Run the command below to enable the grafana virtual host.

Then run an nginx configuration test to ensure that you have configured everything correctly

Finally, restart the nginx web server so that all the changes you have made will become live. Also run a command to set nginx to start automatically at system boot
You can also run the command below to check the status of the nginx service. The command should return information that shows that nginx is active(running)

Open the Grafana dashboard