How to Monitor System Performance with Prometheus on Debian 12 Bookworm

Learn how to monitor system performance with Prometheus on a Debian 12 Bookworm system.

Monitoring is a fundamental aspect of maintaining the health and performance of any modern computing environment. Whether you’re managing a single server or a fleet of cloud instances, having the right tools to gain visibility into system metrics is essential. Prometheus has emerged as a powerful, open-source monitoring and alerting toolkit that excels at collecting and querying time-series data. It’s especially popular in cloud-native environments, but it’s just as effective for standalone systems, including Debian 12 Bookworm.

In this guide, we’ll walk through how to install, configure, and use Prometheus to monitor system performance on a Debian 12 Bookworm system.


Why Use Prometheus?

Prometheus was developed by SoundCloud and is now a part of the Cloud Native Computing Foundation (CNCF). It’s designed to be highly reliable and scalable, with the following key features:

  • Multidimensional data model using time-series data identified by metric name and key/value pairs.
  • Powerful query language called PromQL.
  • No reliance on distributed storage; it stores time-series data on local disk.
  • Pull-based model over HTTP, with optional push support via gateways.
  • Easy service discovery and static configuration.
  • Rich integration with Grafana, Alertmanager, Kubernetes, Docker, and more.

Let’s explore how to bring Prometheus to life on Debian 12.


Step 1: Update Your System

Before installing any packages, make sure your system is up to date.

sudo apt update && sudo apt upgrade -y

This ensures you have the latest package versions and security patches.


Step 2: Create a Prometheus User

For security reasons, Prometheus should not run as root. Create a dedicated user and directories:

sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus

Set the proper ownership:

sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus

Step 3: Download and Install Prometheus

Go to the official Prometheus download page to find the latest version. You can download it using wget:

cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
tar -xvf prometheus-2.52.0.linux-amd64.tar.gz
cd prometheus-2.52.0.linux-amd64

Now copy the binaries and set permissions:

sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool

Move configuration files:

sudo cp -r consoles /etc/prometheus
sudo cp -r console_libraries /etc/prometheus
sudo cp prometheus.yml /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus

Step 4: Create a Prometheus Systemd Service

To make Prometheus manageable via systemctl, create a service file:

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

Paste the following:

[Unit]
Description=Prometheus Monitoring
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
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

[Install]
WantedBy=multi-user.target

Reload systemd and start the Prometheus service:

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus

Check the status:

sudo systemctl status prometheus

By default, Prometheus is accessible at http://localhost:9090.


Step 5: Configure Prometheus to Monitor System Metrics

Prometheus by itself doesn’t gather system metrics like CPU, memory, or disk usage. You need an exporter for that. The most popular one is node_exporter.

Install Node Exporter

cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gz
tar -xvf node_exporter-1.8.1.linux-amd64.tar.gz
cd node_exporter-1.8.1.linux-amd64
sudo cp node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false node_exporter
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter

Create a Systemd Service for Node Exporter

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

Paste:

[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=multi-user.target

Enable and start it:

sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter

Node Exporter will now be running at http://localhost:9100.


Step 6: Add Node Exporter to Prometheus Configuration

Edit your Prometheus configuration file:

sudo nano /etc/prometheus/prometheus.yml

Append the following job to the scrape_configs section:

  - job_name: "node_exporter"
    static_configs:
      - targets: ["localhost:9100"]

Save and restart Prometheus:

sudo systemctl restart prometheus

You can verify the new job by visiting the Prometheus web interface under Status > Targets.


Step 7: Querying Metrics with PromQL

Once the targets are up and running, Prometheus will start collecting data. You can query system performance metrics using PromQL. Here are a few common queries:

  • CPU Usage (per core):

    rate(node_cpu_seconds_total{mode="user"}[1m])
    
  • Memory Usage:

    node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes
    
  • Disk Space Usage:

    node_filesystem_free_bytes / node_filesystem_size_bytes
    

These queries help you understand system load, resource availability, and potential bottlenecks.


Prometheus’s built-in UI is functional but basic. For richer visualizations, install Grafana.

sudo apt install -y apt-transport-https software-properties-common
sudo mkdir -p /etc/apt/keyrings
wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/grafana.gpg > /dev/null
echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee /etc/apt/sources.list.d/grafana.list

sudo apt update
sudo apt install grafana -y

Start and enable the Grafana service:

sudo systemctl enable --now grafana-server

Grafana runs at http://localhost:3000. Default login is admin/admin.

From the dashboard, you can add Prometheus as a data source and import ready-made dashboards, such as “Node Exporter Full” from Grafana Labs (Dashboard ID: 1860).


Security Considerations

Prometheus and Node Exporter expose HTTP endpoints without authentication by default. This is acceptable for internal-only setups but not recommended for public-facing systems. To secure your endpoints:

  • Use a reverse proxy with HTTPS and basic authentication (e.g., Nginx).
  • Restrict access via firewall rules.
  • Run Prometheus behind a VPN for remote access.

Conclusion

Prometheus is a robust and flexible tool that brings deep insights into system performance through a simple and elegant model. On Debian 12 Bookworm, it integrates seamlessly with Node Exporter and Grafana to provide a complete monitoring stack.

By following this guide, you’ve successfully:

  • Installed Prometheus and Node Exporter.
  • Set up Prometheus to collect metrics.
  • Queried metrics using PromQL.
  • Laid the foundation for rich visualization with Grafana.

Once you’re comfortable, you can expand your setup with custom exporters, alerting via Alertmanager, and even federated Prometheus servers for scaling.