Install Prometheus directly on Ubuntu when you want local metrics storage, PromQL, alerting rules, and full control over scraping Linux servers. Prometheus is a CNCF graduated open-source monitoring project, which makes it a safe choice for teams that need a standard tool with broad support [source: CNCF]. Grafana Alloy is better when you need an agent to collect metrics, logs, and traces, then send them to Grafana Cloud, Mimir, Loki, Tempo, or another backend.
TLDR: Use Prometheus if your Ubuntu server should store, query, and alert on metrics locally. Use Grafana Alloy if each Linux server needs a modern collector that ships telemetry elsewhere. For example, a small team with 20 Ubuntu servers scraping every 15 seconds will create about 80 scrape batches per minute, so central Prometheus works well if the network is stable. If those servers sit across several regions, Alloy on each host may be cleaner and less fragile.
Prometheus vs Grafana Alloy: the short version
Prometheus is the monitoring server. It scrapes HTTP endpoints, stores time-series data, runs PromQL queries, and sends alerts through Alertmanager. It is usually the main engine behind Linux metrics dashboards.
Grafana Alloy is a collector. It gathers telemetry from systems and applications. It can collect Prometheus-style metrics, OpenTelemetry data, logs, and traces. Then it sends that data to a storage or observability platform.
The catch is that people often compare them as if they do the same job. They do not. Prometheus answers questions such as, “Why did CPU steal jump at 02:00?” Alloy answers, “How do I collect signals from this box and forward them reliably?”
Image not found in postmetaWhen to install Prometheus on Ubuntu
Install Prometheus on Ubuntu when you need:
- Local metric retention for servers and applications.
- PromQL for direct metric analysis.
- Alert rules based on metric conditions.
- Scraping control from one central place.
- A simple server-first setup without sending data to a cloud service.
For a single data center, a lab, or a small production platform, Prometheus is still hard to beat. It is predictable. It is documented. It also fails in obvious ways, which matters at 3 a.m.
Step 1: create the Prometheus user and directories
Run these commands on your Ubuntu server as a user with sudo rights:
sudo useradd --no-create-home --shell /usr/sbin/nologin prometheus
sudo mkdir -p /etc/prometheus
sudo mkdir -p /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus
sudo chown prometheus:prometheus /var/lib/prometheus
This keeps Prometheus away from your normal user accounts. That is not just neat. It limits damage if something goes wrong.
Step 2: download and install Prometheus
Check the current Linux AMD64 release on the Prometheus releases page, then replace the version below with the current one [source: Prometheus].
cd /tmp
VERSION="2.54.1"
wget https://github.com/prometheus/prometheus/releases/download/v${VERSION}/prometheus-${VERSION}.linux-amd64.tar.gz
tar xvf prometheus-${VERSION}.linux-amd64.tar.gz
cd prometheus-${VERSION}.linux-amd64
sudo cp prometheus promtool /usr/local/bin/
sudo cp -r consoles console_libraries /etc/prometheus/
sudo chown prometheus:prometheus /usr/local/bin/prometheus
sudo chown prometheus:prometheus /usr/local/bin/promtool
sudo chown -R prometheus:prometheus /etc/prometheus
Ubuntu repositories may include Prometheus packages, but they are often behind upstream releases. Honestly, it feels like a small annoyance until a bug fix or feature is missing. The binary install gives you clearer version control.
Step 3: create the Prometheus configuration
Create the main config file:
sudo nano /etc/prometheus/prometheus.yml
Add this minimal configuration:
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
Set ownership:
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
This config only scrapes Prometheus itself. For Linux server metrics, you also need Node Exporter.
Step 4: create a systemd service
Create the service file:
sudo nano /etc/systemd/system/prometheus.service
Paste this:
[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 \
--storage.tsdb.retention.time=15d
Restart=on-failure
[Install]
WantedBy=multi-user.target
Start Prometheus:
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
Open the web interface at:
http://your_server_ip:9090
If UFW is active, allow access only from trusted IPs. Do not expose port 9090 to the public internet.
Step 5: add Linux server metrics with Node Exporter
Prometheus needs exporters to collect host metrics. For Linux servers, use Node Exporter. It reports CPU, memory, disk, filesystem, network, and load metrics.
Install Node Exporter on each Linux server you want to monitor. After it is running on port 9100, add it to Prometheus:
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "linux_servers"
static_configs:
- targets:
- "192.168.1.20:9100"
- "192.168.1.21:9100"
- "192.168.1.22:9100"
Reload Prometheus:
sudo systemctl restart prometheus
Then test a query:
node_load1
Where Grafana Alloy fits
Grafana Alloy can run on each Ubuntu server and collect host metrics, application metrics, logs, and traces. It is useful when your monitoring setup is not just Prometheus metrics anymore.
Pick Alloy when you need:
- One collector for metrics, logs, and traces.
- Remote write to Grafana Cloud, Mimir, or another backend.
- Fleet-wide agent configuration across many servers.
- OpenTelemetry support without running several separate agents.
Alloy does not replace Prometheus in every setup. It can send metrics to a Prometheus-compatible backend, and Prometheus can scrape endpoints that Alloy exposes. The better design depends on where you want data stored and queried.
Which setup should you choose?
- One to ten servers: Prometheus plus Node Exporter is simple and reliable.
- Ten to fifty servers: Prometheus still works well, but plan retention, disk space, and scrape intervals.
- Many regions or remote sites: Alloy on each server may be easier than exposing many scrape targets.
- Metrics only: Prometheus is usually enough.
- Metrics, logs, and traces: Alloy is often the cleaner agent layer.
A practical production setup often uses both. Alloy collects telemetry from Linux servers. Prometheus or a Prometheus-compatible backend stores and queries the metrics. Grafana displays dashboards. Alertmanager sends alerts.
Basic hardening tips
- Run Prometheus as a dedicated non-root user.
- Keep port 9090 private or behind a VPN.
- Use firewall rules for Node Exporter port 9100.
- Set a retention period that matches disk capacity.
- Back up important rule files and configuration.
- Use labels such as env, region, and role early.
The serious recommendation is simple: install Prometheus on Ubuntu if you need a dependable monitoring server today. Add Node Exporter for Linux metrics. Bring in Grafana Alloy when your estate grows, when servers sit behind awkward networks, or when logs and traces need the same collection path as metrics.