Server AdministrationUpdated November 24, 2026·5 min read

How to Monitor Your Server with Prometheus on Ubuntu

Prometheus fetches metrics from your infrastructure, such as CPU usage, memory, disk space and request counts, and stores them as time series you can query and alert on. To install Prometheus on Ubuntu, you can use the fast but older package provided by Ubuntu, or the current official build, with a little more effort required. This article takes the quick route first and gets a server monitored in five steps, then shows when and how to switch to the official binary.

How Prometheus fits together

Prometheus fetches metrics. At regular intervals (every few seconds), it queries over HTTP some number of targets to get a set of numeric values. The components:

  • Prometheus server: scrapes metrics, saves them, runs queries. Web interface listening at port 9090.
  • Metrics exporters: tiny programs which expose metrics from systems unable to speak to Prometheus directly. node_exporter is our exporter for the Linux machine itself at port 9100.
  • Grafana: draws dashboards based on metrics from Prometheus. Optional component.

Thus a minimal configuration is one Prometheus instance plus node_exporter running on each monitored machine, which is exactly what the five steps below build.

Step 1: install Prometheus on Ubuntu, with node_exporter

sudo apt update
sudo apt install prometheus prometheus-node-exporter
systemctl status prometheus prometheus-node-exporter

The configuration file is /etc/prometheus/prometheus.yml, and additional options should be included into /etc/default/prometheus. Ubuntu ships Prometheus 2.45 on 24.04 and 2.53 on 26.04, which is plenty for watching a few servers.

Step 2: tell Prometheus to scrape node_exporter

Add a job to prometheus.yml under scrape_configs:

scrape_configs:
  - job_name: "node"
    static_configs:
      - targets: ["localhost:9100"]

Check the file, then reload:

promtool check config /etc/prometheus/prometheus.yml
sudo systemctl restart prometheus

To add more nodes, simply add the host:9100 addresses of these servers into the list, and in each machine's firewall, allow port 9100 only from the Prometheus server.

Step 3: keep the web UI private

By default, Prometheus has no login. Every metric can be read simply by reaching port 9090. Add --web.listen-address=127.0.0.1:9090 to ARGS in /etc/default/prometheus and restart. Now, access the interface via SSH tunneling:

ssh -L 9090:localhost:9090 user@your-server

and browse to http://localhost:9090. Verify which services are listening using sudo ss -tlnp; our Linux network commands cheat sheet will explain the output.

Step 4: run your first queries

Open the Query page and try:

Query Shows
up 1 for every target Prometheus can reach, 0 for the ones it cannot
node_load1 One-minute load average per server
100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) CPU use in percent
node_filesystem_avail_bytes{mountpoint="/"} Free space on the root disk

Step 5: add dashboards and alerts

When everything is fine, the logical extension is to use Grafana for dashboarding, and Prometheus even has its own alerting rules to warn you before your disk becomes full. Grafana reads straight from Prometheus as a data source. Alerting rules go in a file listed under rule_files in prometheus.yml, and Alertmanager sends the notifications by email or chat.

When to switch to the official 3.x binary

Ubuntu's package lags behind upstream. Move to the official release when you need Prometheus 3 features or the newest fixes:

Ubuntu package (apt install prometheus) Official binary
Version 2.45 on Ubuntu 24.04, 2.53 on Ubuntu 26.04 3.16.0 as of November 2026
Updates With apt upgrade Manual: download the new release
Service and user Set up for you You create them
Best for Getting started, small setups Current features, Prometheus 3

Install the official binary

If you are replacing the apt version, remove it first with sudo apt remove prometheus; the node_exporter package stays and works fine alongside the official binary.

Create a user, then make directories, followed by downloading and un-tarring the release:

sudo useradd --system --no-create-home --shell /usr/sbin/nologin prometheus
sudo mkdir -p /etc/prometheus /var/lib/prometheus
wget https://github.com/prometheus/prometheus/releases/download/v3.16.0/prometheus-3.16.0.linux-amd64.tar.gz
tar -xzf prometheus-3.16.0.linux-amd64.tar.gz
cd prometheus-3.16.0.linux-amd64
sudo cp prometheus promtool /usr/local/bin/
sudo cp prometheus.yml /etc/prometheus/
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus

Before you download, look for a newer version on the releases page and change the number in all three places.

Next you can make /etc/systemd/system/prometheus.service:

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

[Service]
User=prometheus
ExecStart=/usr/local/bin/prometheus \
  --config.file=/etc/prometheus/prometheus.yml \
  --storage.tsdb.path=/var/lib/prometheus \
  --web.listen-address=127.0.0.1:9090
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus

The binary starts with its own sample prometheus.yml, so add the node job from Step 2 to it again and restart.

Monitoring really pays off on the working machines. Watch our bare metal servers or a fleet of VPS instances with just one small Prometheus server.

Was this article helpful?

Written by Julius · Product Manager