Prometheus on Ubuntu

[2 min installs] Prometheus on Ubuntu

Better Stack Team
Updated on August 30, 2022

Prometheus is a powerful open-source monitoring system that can collect metrics from various sources, store them, and visualize them in a web interface. In this guide, we will walk you through the installation process of Prometheus on Ubuntu 20.04 in under two minutes.


Before we start, you need to ensure that you have the following:

  • Ubuntu 20.04 operating system up and running
  • Sudo privileges on your user account

Step 1 - Update the System

Before you install any new packages, it is recommended to update the system to the latest packages. To do this, run the following command in your terminal:

sudo apt update && sudo apt upgrade

Step 2 - Install Prometheus

Prometheus is not available in the default Ubuntu package repository. But it comes in precompiled binaries compressed into a .tar or .zip file. To download Prometheus, head over to the official download page or to the official GitHub repository. At the moment of writing this guide, the latest version of Prometheus is 2.43.0.

First, we need to create the configuration and data directories for Prometheus.

Create a configuration directory for Prometheus by running the following command:

sudo mkdir -p /etc/prometheus

For the data directory, execute:

sudo mkdir -p /var/lib/prometheus

Once the directories are created, download the compressed installation file from the GitHub repository. Note that this link may no longer be valid. To get the current version of Prometheus, go to the official GitHub repository, navigate to Releases, and select the version you wish to download.


Now, extract the downloaded file:

tar -xvf prometheus-2.31.3.linux-amd64.tar.gz

Navigate to the Prometheus folder:

cd prometheus-2.31.3.linux-amd64

Once in the directory move the  prometheus and promtool binary files to /usr/local/bin/ folder:

sudo mv prometheus promtool /usr/local/bin/

Move console files in console directory and library files in the console_libraries  directory to /etc/prometheus/ directory.

sudo mv consoles/ console_libraries/ /etc/prometheus/

Move the prometheus.yml template configuration file to the  /etc/prometheus/ directory.

sudo mv prometheus.yml /etc/prometheus/prometheus.yml

It was quite a lot of steps, but fortunately, this is all for the installation part. Make sure that everything worked by running the following command the will print the Prometheus version:

prometheus --version
promtool --version

Step 3 - Create a Prometheus group and user

It is strongly recommended that we create a Prometheus group and user before proceeding to the next step which involves creating a system file for Prometheus.

To  create a prometheus group execute the following command:

sudo groupadd --system prometheus

Create prometheus user and assign it to the just-created prometheus group:

sudo useradd -s /sbin/nologin --system -g prometheus prometheus

Next, configure the directory ownership and permissions as shown below:

sudo chown -R prometheus:prometheus /etc/prometheus/ /var/lib/prometheus/
sudo chmod -R 775 /etc/prometheus/ /var/lib/prometheus/

That’s it for this step. Now, prometheus user and group are created and you can move on the next step.

Step 4 - Create a systemd file for Prometheus

Create and open a new systemd file for Prometheus using your favorite text editor. In this guide, we will use nano

sudo nano /etc/systemd/system/prometheus.service

Copy and paste the following configuration into the newly created file:


ExecStart=/usr/local/bin/prometheus \
    --config.file=/etc/prometheus/prometheus.yml \
    --storage.tsdb.path=/var/lib/prometheus/ \
    --web.console.templates=/etc/prometheus/consoles \
    --web.console.libraries=/etc/prometheus/console_libraries \


Save the changes and exit the systemd file. In the nano editor, press Ctr + O to write the changes, confirm with Enter, and press Ctrl + X to exit the editor.

Now, start the Prometheus service:

sudo systemctl start prometheus

Enable the Prometheus service to run at startup:

sudo systemctl enable prometheus

That’s it for this step. Check that everything works so far by checking the status of the Prometheus service:

sudo systemctl status prometheus

Step 5 - Access Prometheus Web Interface

Prometheus web interface is available on port 9090 by default.

If you have a UFW firewall running, open the 9090 port:

sudo ufw allow 9090/tcp
sudo ufw reload

To access the Prometheus web interface, open your web browser and navigate to http://localhost:9090/ or http://SERVER_IP:9090/.


Congratulations! You have successfully installed Prometheus on Ubuntu 20.04. Now you can explore the Prometheus web interface to visualize the metrics collected from different sources. With Prometheus, you can monitor the performance of your systems and applications and identify potential issues before they become a problem.

Check Uptime, Ping, Ports, SSL and more.
Get Slack, SMS and phone incident alerts.
Easy on-call duty scheduling.
Create free status page on your domain.
Got an article suggestion? Let us know
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.