Prometheus is an open-source metrics collection and alerting system, while Grafana provides beautiful dashboards for visualising those metrics. Together they form the most popular open-source monitoring stack. This guide installs both on Ubuntu 26.04 LTS with Nginx and SSL.
Tested and valid on:
- Ubuntu 26.04 LTS
Prerequisites
- Ubuntu 26.04 LTS with Nginx installed
- A user with sudo privileges
- Ports 9090 (Prometheus) and 3000 (Grafana) available
Step 1 – Create System Users
sudo useradd --no-create-home --shell /bin/false prometheus
sudo useradd --no-create-home --shell /bin/false node_exporter
Step 2 – Install Prometheus
PROM_VER=$(curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest | grep -Po '"tag_name": "vK[^"]*')
wget https://github.com/prometheus/prometheus/releases/download/v${PROM_VER}/prometheus-${PROM_VER}.linux-amd64.tar.gz -P /tmp
tar xzf /tmp/prometheus-${PROM_VER}.linux-amd64.tar.gz -C /tmp
sudo mv /tmp/prometheus-${PROM_VER}.linux-amd64/{prometheus,promtool} /usr/local/bin/
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
Step 3 – Configure Prometheus
sudo nano /etc/prometheus/prometheus.yml
Add:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Step 4 – Create a Prometheus systemd Service
sudo nano /etc/systemd/system/prometheus.service
Add:
[Unit]
Description=Prometheus
After=network.target
[Service]
User=prometheus
ExecStart=/usr/local/bin/prometheus
--config.file=/etc/prometheus/prometheus.yml
--storage.tsdb.path=/var/lib/prometheus
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus
Step 5 – Install Node Exporter
NE_VER=$(curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest | grep -Po '"tag_name": "vK[^"]*')
wget https://github.com/prometheus/node_exporter/releases/download/v${NE_VER}/node_exporter-${NE_VER}.linux-amd64.tar.gz -P /tmp
tar xzf /tmp/node_exporter-${NE_VER}.linux-amd64.tar.gz -C /tmp
sudo mv /tmp/node_exporter-${NE_VER}.linux-amd64/node_exporter /usr/local/bin/
sudo nano /etc/systemd/system/node_exporter.service
Add:
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=node_exporter
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
Step 6 – Install Grafana
sudo apt install -y apt-transport-https software-properties-common
wget -q -O - https://packages.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://packages.grafana.com/oss/deb stable main' | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update && sudo apt install grafana -y
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
Step 7 – Connect Grafana to Prometheus
Visit http://your-server:3000 (admin/admin). Go to Connections → Data Sources → Prometheus and set the URL to http://localhost:9090. Import dashboard ID 1860 for the Node Exporter Full dashboard.
Conclusion
Prometheus and Grafana are running on Ubuntu 26.04 LTS. You now have a full metrics monitoring stack with real-time dashboards. Add more exporters (MySQL, Nginx, Redis) to extend coverage.