How to Install Prometheus on Debian Latest

Prometheus is an open-source monitoring system that collects and stores metrics information from various resources like servers, applications, and microservices. Installing Prometheus on Debian is a straightforward process that requires following a few simple steps.

In this tutorial, we will cover how to install Prometheus on Debian latest version.

Prerequisites

Before we begin, make sure your system meets the following prerequisites:

Step 1: Update the System

Update the installed packages and repositories on your Debian system by running the following command:

sudo apt-get update

Step 2: Install and Configure Prometheus

  1. Download the Prometheus package by running the following command:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
  1. Extract the downloaded tarball using the following command:
tar xvf prometheus-2.30.3.linux-amd64.tar.gz
  1. Move the extracted directory to the /opt directory using the following command:
sudo mv prometheus-2.30.3.linux-amd64 /opt/prometheus
  1. Create a new user and group for Prometheus using the following command:
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
  1. Set the ownership of the Prometheus directory to the newly created user and group using the following command:
sudo chown -R prometheus:prometheus /opt/prometheus/
  1. Open a configuration file for Prometheus using the following command:
nano /opt/prometheus/prometheus.yml
  1. Add the following configuration to the file:
global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']
  1. Save and close the configuration file.

  2. Create a systemd service file for Prometheus using the following command:

sudo nano /etc/systemd/system/prometheus.service
  1. Add the following configuration to the file:
[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data

[Install]
WantedBy=multi-user.target
  1. Save and close the file.

  2. Reload the systemd daemon and start the Prometheus service using the following command:

sudo systemctl daemon-reload
sudo systemctl enable --now prometheus

Step 3: Accessing the Prometheus UI

Prometheus UI can be accessed on the web browser by accessing the following URL:

http://<your-server-IP>:9090/

Congratulations! You have successfully installed Prometheus on your Debian system. You can now use Prometheus to collect, store and analyze metrics information from various sources.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!