// ssd vps

How to Install and Configure Prometheus and Grafana on a Linux VPS: Complete Server Monitoring Guide

September 02, 2026 · by Alex M.

How to Install and Configure Prometheus and Grafana on a Linux VPS: Complete Server Monitoring Guide

Server monitoring is one of the most critical DevOps practices you should implement from day one. Without real-time metrics, performance issues — excessive CPU consumption, memory exhaustion, full disks — can go unnoticed until your site or application crashes entirely.

Prometheus and Grafana together form one of the most widely used open-source monitoring stacks. Prometheus collects and stores metrics, while Grafana visualizes them in elegant, interactive dashboards. In this complete guide, you'll learn how to install and configure both tools step by step on a SSD VPS running Ubuntu 22.04.

Why Prometheus + Grafana?

There are many monitoring solutions — Zabbix, Netdata, Nagios — but the Prometheus + Grafana combination continues to gain ground because of:

  • Scalability: works equally well on a small VPS or a cluster with hundreds of nodes
  • Flexibility: hundreds of exporters available for Nginx, MySQL, PostgreSQL, Docker and more
  • Active community: ready-made dashboards available at grafana.com/grafana/dashboards
  • Easy integration with Alertmanager, CI/CD pipelines and other DevOps tools

If you're running an NVMe VPS with critical applications, these tools can save you hours of troubleshooting.

Prerequisites

Before you start, make sure you have:

  • A VPS running Ubuntu 22.04 (minimum 1 vCPU, 1 GB RAM — 2 GB recommended)
  • Root access or a user with sudo privileges
  • SSH configured and a UFW firewall active
  • A domain name or public IP address

Update your system before anything else:

sudo apt update && sudo apt upgrade -y

Step 1: Install Prometheus

1.1 Create a Dedicated User

Never run Prometheus as root. Create a system user with no login shell:

sudo useradd --no-create-home --shell /bin/false prometheus

1.2 Download and Install Prometheus

Check the latest release at prometheus.io/download, then:

cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
tar xvf prometheus-2.52.0.linux-amd64.tar.gz
cd prometheus-2.52.0.linux-amd64

Copy the binaries and configuration files:

sudo cp prometheus /usr/local/bin/
sudo cp promtool /usr/local/bin/
sudo mkdir /etc/prometheus
sudo mkdir /var/lib/prometheus
sudo cp -r consoles/ /etc/prometheus/
sudo cp -r console_libraries/ /etc/prometheus/
sudo cp prometheus.yml /etc/prometheus/

Set correct ownership:

sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool

1.3 Configure prometheus.yml

Edit the main configuration file:

sudo nano /etc/prometheus/prometheus.yml

Basic content:

global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['localhost:9090']

  - job_name: 'node'
    static_configs:
      - targets: ['localhost:9100']

1.4 Create the systemd Service

sudo nano /etc/systemd/system/prometheus.service
[Unit]
Description=Prometheus Monitoring
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/prometheus \n  --config.file=/etc/prometheus/prometheus.yml \n  --storage.tsdb.path=/var/lib/prometheus/ \n  --web.console.templates=/etc/prometheus/consoles \n  --web.console.libraries=/etc/prometheus/console_libraries
Restart=on-failure

[Install]
WantedBy=multi-user.target

Enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus

Prometheus is now running on port 9090. If UFW is active:

sudo ufw allow 9090/tcp

Step 2: Install Node Exporter

Node Exporter exposes operating system metrics (CPU, RAM, disk, network) to Prometheus.

2.1 Download Node Exporter

cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xvf node_exporter-1.8.0.linux-amd64.tar.gz
sudo cp node_exporter-1.8.0.linux-amd64/node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false node_exporter
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter

2.2 Create the systemd Service

sudo nano /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable node_exporter
sudo systemctl start node_exporter

Node Exporter runs on port 9100 and exposes hundreds of metrics about your server's health.

Step 3: Install Grafana

Grafana transforms raw Prometheus data into intuitive visual charts. This is where you'll actually see — in real time — everything happening on your VPS.

3.1 Add the Official Grafana Repository

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

3.2 Start Grafana

sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-server

Grafana runs on port 3000:

sudo ufw allow 3000/tcp

Open http://YOUR-VPS-IP:3000 in your browser. Default credentials: admin / admin. You'll be prompted to change the password on first login.

Step 4: Connect Prometheus to Grafana

4.1 Add a Data Source

  1. In Grafana, go to Configuration → Data Sources → Add data source
  2. Select Prometheus
  3. In the URL field enter: http://localhost:9090
  4. Click Save & Test — you should see the message "Data source is working"

4.2 Import a Pre-Built Dashboard

Instead of building charts from scratch, import the popular Node Exporter Full dashboard (ID: 1860):

  1. Go to Dashboards → Import
  2. Enter ID 1860 and click Load
  3. Select the Prometheus data source you just created
  4. Click Import

You'll instantly see graphs for CPU usage, load average, available memory, disk I/O, network traffic and much more.

Step 5: Secure Access with an Nginx Reverse Proxy

Don't expose Grafana and Prometheus directly to the internet without protection. Set up Nginx as a reverse proxy and add an SSL certificate for an encrypted connection.

5.1 Install Nginx

sudo apt install nginx -y

5.2 Configure a Virtual Host for Grafana

sudo nano /etc/nginx/sites-available/grafana
server {
    listen 80;
    server_name monitoring.yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
sudo ln -s /etc/nginx/sites-available/grafana /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Add SSL with Certbot:

sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d monitoring.yourdomain.com

Prometheus can send alerts when metrics exceed defined thresholds. For example, an alert when CPU > 85% for 5 minutes:

# /etc/prometheus/alert.rules.yml
groups:
  - name: server_alerts
    rules:
      - alert: HighCPUUsage
        expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 85
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "High CPU on {{ $labels.instance }}"
          description: "CPU usage > 85% for 5 minutes"

      - alert: LowDiskSpace
        expr: (node_filesystem_avail_bytes / node_filesystem_size_bytes) * 100 < 10
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "Critical disk space on {{ $labels.instance }}"

Reference the file in prometheus.yml:

rule_files:
  - "/etc/prometheus/alert.rules.yml"

Optimisation Tips and Best Practices

  • Data retention: Prometheus keeps data for 15 days by default. Override with --storage.tsdb.retention.time=30d in the systemd service
  • Regular backups: export configurations and TSDB snapshots. With a managed VPS, you can delegate this task to our team
  • Grafana authentication: enable LDAP or OAuth for larger teams
  • Additional exporters: add mysqld_exporter for databases, nginx_exporter for the web server, blackbox_exporter for external URL monitoring
  • Service separation: in production, run Grafana and Prometheus on separate machines or use a dedicated server with guaranteed resources

Quick Checks After Installation

# Verify Prometheus is scraping data
curl http://localhost:9090/api/v1/targets

# Check Node Exporter metrics
curl http://localhost:9100/metrics | grep node_cpu

# Check the status of all services
sudo systemctl status prometheus node_exporter grafana-server

Conclusion

You've now built a complete server monitoring system: metric collection through Prometheus, real-time visualization through Grafana, and automatic alerting via custom rules. This stack gives you full visibility into your VPS's health, helping you act proactively before issues impact your users.

If you'd rather focus on your application than your infrastructure, CLIQHOST server management services include monitoring, maintenance and specialized technical support. Or you can get started right now with a high-performance SSD VPS and implement this setup yourself. Need help? Contact us — we're here for you.

SHARE
// what clients say

What Our Clients Say

Real reviews from customers who trust CLIQHOST for performance, reliability and expert technical support.

★★★★★

"We moved our online shop from a foreign host and the difference is night and day — pages load instantly and support replies in minutes, in Romanian."

AM
Andrei M.
eCommerce owner · Chișinău
★★★★★

"Migrated 12 client sites to CLIQHOST. Free migration, zero downtime, and the cPanel setup is exactly what my team needed. Highly recommend."

EV
Elena V.
Web agency · Bălți
★★★★★

"Our NVMe VPS handles traffic spikes without a sweat. Full root, local datacenter, and billing in MDL — everything we wanted from a provider."

DC
Dmitri C.
SaaS founder · Chișinău