Prerequisites
Before installing Prometheus, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
- At least 2GB RAM (for Prometheus)
💡 Prometheus is a powerful time-series database used with Grafana for advanced server monitoring dashboards.
Step 1: Install Node Exporter (Collects metrics)
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
wget https://github.com/prometheus/node_exporter/releases/download/v1.6.0/node_exporter-1.6.0.linux-amd64.tar.gz
tar xvf node_exporter-1.6.0.linux-amd64.tar.gz
sudo mv node_exporter-1.6.0.linux-amd64/node_exporter /usr/local/bin/
rm -rf node_exporter-1.6.0.linux-amd64*
Create systemd service:
sudo nano /etc/systemd/system/node_exporter.service
Add:
[Unit]
Description=Node Exporter
After=network.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
Start and enable:
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl enable node_exporter
Verify (port 9100):
curl http://localhost:9100/metrics
Step 2: Install Prometheus
wget https://github.com/prometheus/prometheus/releases/download/v2.47.0/prometheus-2.47.0.linux-amd64.tar.gz
tar xvf prometheus-2.47.0.linux-amd64.tar.gz
sudo mv prometheus-2.47.0.linux-amd64 /opt/prometheus
Create config:
sudo nano /opt/prometheus/prometheus.yml
Add:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9100']
Create systemd service:
sudo nano /etc/systemd/system/prometheus.service
Add:
[Unit]
Description=Prometheus
After=network.target
[Service]
Type=simple
User=nobody
ExecStart=/opt/prometheus/prometheus --config.file=/opt/prometheus/prometheus.yml --storage.tsdb.path=/opt/prometheus/data
[Install]
WantedBy=multi-user.target
Start and enable:
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus
Allow firewall (port 9090):
sudo ufw allow 9090/tcp
Step 3: Access Prometheus Dashboard
Open browser:
http://YOUR_VPS_IP:9090
You can query metrics like node_cpu_seconds_total.
Step 4: Install Grafana (Optional, for beautiful dashboards)
sudo apt install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
sudo apt update
sudo apt install grafana -y
sudo systemctl start grafana-server
sudo systemctl enable grafana-server
sudo ufw allow 3000/tcp
Access Grafana at http://YOUR_VPS_IP:3000 (default admin/admin).
Add Prometheus as data source (URL: http://localhost:9090).
Import dashboard ID 1860 for Node Exporter.
✅ Prometheus and Node Exporter installed. Advanced monitoring is ready.