Prometheus collects and stores time-series metrics, while Grafana visualizes them in customizable dashboards — together forming the most widely used open-source monitoring stack, well-suited for monitoring multiple servers from a central location.
Prerequisites
- Ubuntu 22.04/24.04 or Debian 11/12 VPS
- Root or sudo access
- At least 2 GB RAM recommended for the monitoring server
Step 1 — Install Prometheus
sudo useradd --no-create-home --shell /bin/false prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.53.0/prometheus-2.53.0.linux-amd64.tar.gz
tar xvf prometheus-2.53.0.linux-amd64.tar.gz
sudo cp prometheus-2.53.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.53.0.linux-amd64/promtool /usr/local/bin/
sudo mkdir /etc/prometheus /var/lib/prometheus
sudo cp -r prometheus-2.53.0.linux-amd64/consoles /etc/prometheus
sudo cp -r prometheus-2.53.0.linux-amd64/console_libraries /etc/prometheus
Check for the current version at Prometheus's official releases page and adjust the version number accordingly.
Step 2 — Create the Configuration File
sudo nano /etc/prometheus/prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Step 3 — Create a systemd Service
sudo nano /etc/systemd/system/prometheus.service
[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
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now prometheus
Step 4 — Install Node Exporter (Collects Server Metrics)
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.2/node_exporter-1.8.2.linux-amd64.tar.gz
tar xvf node_exporter-1.8.2.linux-amd64.tar.gz
sudo cp node_exporter-1.8.2.linux-amd64/node_exporter /usr/local/bin/
sudo nano /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=prometheus
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter
Step 5 — Install Grafana
sudo apt install -y apt-transport-https software-properties-common
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb 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 enable --now grafana-server
Step 6 — Access Grafana
http://YOUR_SERVER_IP:3000
Default login is admin/admin — you'll be prompted to change the password on first login.
Step 7 — Add Prometheus as a Data Source
In Grafana: Connections → Data Sources → Add data source → Prometheus, set the URL to http://localhost:9090.
Step 8 — Import a Pre-Built Dashboard
Grafana's dashboard marketplace has ready-made dashboards for Node Exporter (search for "Node Exporter Full") — import one by ID rather than building from scratch.
Step 9 — Restrict Access
sudo ufw deny 9090/tcp
sudo ufw deny 3000/tcp
sudo ufw allow from YOUR_TRUSTED_IP to any port 3000
Monitoring Multiple Servers
Install Node Exporter on each additional VPS, then add each as a separate target in prometheus.yml:
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['server1:9100', 'server2:9100']
Common Errors
Grafana shows "No data" — verify Prometheus is actually scraping successfully at http://localhost:9090/targets.
Node Exporter unreachable from a remote Prometheus server — confirm port 9100 is allowed through the firewall for the specific Prometheus server's IP.
Best Practices
- Never expose Prometheus or Grafana publicly without authentication/IP restriction
- Use pre-built community dashboards rather than building from scratch
- Set up alerting rules for critical thresholds, not just visual dashboards
Related Articles
- How to Install Netdata for Real-Time VPS Monitoring
- How to Set Up Uptime Monitoring for Your Website
- How to Configure UFW Firewall on a Linux VPS
