How To Install Prometheus on Debian 11

Install Prometheus on Debian 11

In this article, we will have explained the necessary steps to install Prometheus on Debian 11. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Prometheus is an open-source system monitoring and alerting tool. It collects metrics from configured targets at given intervals, evaluates rule expressions, displays the results, and can trigger alerts if some condition is observed to be true.

Install Prometheus on Debian 11

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo apt update
sudo apt upgrade

Step 2. Create a dedicated user and group for Prometheus.

We create users and group Prometheus using the following command:

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

Step 3. Install Prometheus on Debian system.

Run the following command to download the latest version of Prometheus:

curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest|grep browser_download_url|grep linux-amd64|cut -d '"' -f 4|wget -qi -

Next, extract the downloaded file and change the directory to the extracted directory:

tar -xvf prometheus*.tar.gz
cd prometheus-2.30.3.linux-amd64

Then, create some required directories:

mkdir /etc/prometheus
mkdir /var/lib/prometheus

After that, copy the required configuration files and tools:

mv prometheus.yml /etc/prometheus/prometheus.yml
mv consoles/ console_libraries/ /etc/prometheus/
mv prometheus promtool /usr/local/bin/

Step 4. Create Systemd Service Unit for Prometheus.

We create a systemd service file to manage the Prometheus service:

nano /etc/systemd/system/prometheus.service

Add the following directives to this file:

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
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 \
  --web.listen-address=0.0.0.0:9090 \
  --web.external-url=

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target

Save the file then set proper ownership and permission:

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

Next, start the Prometheus service and enable it to start at system reboot using the following command:

systemctl start prometheus
systemctl enable prometheus

Step 5. Configure Linux Firewall for Prometheus.

Open Prometheus port on the firewall (UFW) if it is running:

sudo ufw allow 9090/tcp

Step 6. Accessing Prometheus.

The Prometheus application is now has been ready to receive web requests. We can access it via a web browser using the address, http://server-IP-address:9090.

Install Prometheus on Debian 11

That’s all you need to do to install the Prometheus on Debian (Bullseye). I hope you find this quick tip helpful. For further reading Prometheus monitoring system & time-series database on Debian’s system, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.