Skip to content
-
Subscribe to our newsletter & never miss our best posts. Subscribe Now!
Devnix Blog

Tech Trends, Software Engineering & Cloud Insights

Devnix Blog

Tech Trends, Software Engineering & Cloud Insights

  • Home
  • Privacy Policy
  • Home
  • Privacy Policy
Close

Search

Subscribe
Cloud VPS Performance

How to Install and Configure Prometheus + Grafana on a Linux Cloud VPS

By Devnix
May 23, 2026 3 Min Read
0


How to Install and Configure Prometheus + Grafana on a Linux Cloud VPS

Problem statement: Modern applications need real‑time visibility into CPU, memory, disk I/O, and custom application metrics. Without a proper monitoring stack, you’re forced to react to incidents after they happen, leading to downtime and lost revenue. This tutorial walks you through provisioning a minimal Cloud VPS, installing Prometheus for metrics collection, and visualizing those metrics with Grafana.

Prerequisites

  • A fresh Linux server (Ubuntu 22.04 LTS recommended) with root or sudo access.
  • Basic knowledge of systemd services and firewall configuration.
  • SSH client installed on your workstation.
  • Port 22 (SSH) open, and ports 9090 (Prometheus) and 3000 (Grafana) allowed in the firewall.

Step 1 – Provision a Cloud VPS

Start with a lightweight instance that gives you enough CPU and RAM for both Prometheus and Grafana. You can rely on DevNix Cloud VPS to spin up a 1 vCPU / 1024 MB RAM server in minutes. After the order completes, you’ll receive an IP address and SSH credentials.

Step 2 – Secure the Server and Install Essentials

2.1 Update the OS

sudo apt update && sudo apt upgrade -y

2.2 Install required packages

sudo apt install -y curl wget gnupg2 software-properties-common

2.3 Harden SSH (optional but recommended)

sudo sed -i 's/^#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo systemctl restart sshd

Step 3 – Install Prometheus

3.1 Create a dedicated user

sudo useradd --no-create-home --shell /usr/sbin/nologin prometheus

3.2 Download the latest binary

Check the official download page for the current version. The example below uses v2.53.0.

wget https://github.com/prometheus/prometheus/releases/download/v2.53.0/prometheus-2.53.0.linux-amd64.tar.gz
tar xzf prometheus-2.53.0.linux-amd64.tar.gz
sudo mv prometheus-2.53.0.linux-amd64/prometheus /usr/local/bin/
sudo mv prometheus-2.53.0.linux-amd64/promtool /usr/local/bin/
sudo mkdir -p /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/

3.3 Set ownership

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

3.4 Create the main configuration file

sudo tee /etc/prometheus/prometheus.yml > /dev/null <<'EOF'
global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: 'node_exporter'
    static_configs:
      - targets: ['localhost:9100']
EOF

3.5 Define a systemd service

sudo tee /etc/systemd/system/prometheus.service > /dev/null <<'EOF'
[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

[Install]
WantedBy=multi-user.target
EOF

3.6 Start and enable Prometheus

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

Step 4 – Install Node Exporter (system metrics)

wget https://github.com/prometheus/node_exporter/releases/download/v1.8.0/node_exporter-1.8.0.linux-amd64.tar.gz
tar xzf node_exporter-1.8.0.linux-amd64.tar.gz
sudo mv node_exporter-1.8.0.linux-amd64/node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /usr/sbin/nologin nodeusr
sudo chown nodeusr:nodeusr /usr/local/bin/node_exporter

sudo tee /etc/systemd/system/node_exporter.service > /dev/null <<'EOF'
[Unit]
Description=Prometheus Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=nodeusr
Group=nodeusr
Type=simple
ExecStart=/usr/local/bin/node_exporter

[Install]
WantedBy=default.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter

Step 5 – Install Grafana

5.1 Add Grafana APT repository

sudo apt-get install -y apt-transport-https software-properties-common wget
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

5.2 Install the package

sudo apt install -y grafana

5.3 Enable and start Grafana

sudo systemctl enable --now grafana-server
sudo systemctl status grafana-server

Step 6 – Configure Firewall (UFW example)

sudo ufw allow OpenSSH
sudo ufw allow 9090/tcp   # Prometheus UI
sudo ufw allow 3000/tcp   # Grafana UI
sudo ufw enable

Step 7 – Connect Grafana to Prometheus

  1. Open a browser and navigate to http://<VPS_IP>:3000. Default credentials are admin / admin (you’ll be prompted to change the password).
  2. In Grafana, click **Configuration → Data Sources → Add data source**.
  3. Select **Prometheus**.
  4. Set the URL to http://<VPS_IP>:9090 and click **Save & Test**. You should see a green confirmation.
  5. Import a ready‑made dashboard (e.g., “Node Exporter Full”) from the Grafana dashboard repository to instantly visualize CPU, memory, disk, and network metrics.

Step 8 – Optional: Enable Persistent Storage for Prometheus

Prometheus stores time‑series data under /var/lib/prometheus. For production use, mount a separate SSD volume or use a network block device to avoid data loss during OS upgrades.

# Example: attach a 20 GB volume (assuming /dev/vdb)
sudo mkfs.ext4 /dev/vdb
sudo mkdir -p /mnt/prometheus
sudo mount /dev/vdb /mnt/prometheus
sudo rsync -a /var/lib/prometheus/ /mnt/prometheus/
sudo umount /var/lib/prometheus
sudo mount /dev/vdb /var/lib/prometheus
sudo chown -R prometheus:prometheus /var/lib/prometheus

Conclusion

With a modest Cloud VPS you now have a fully functional monitoring stack: Prometheus scrapes system metrics via Node Exporter, stores them efficiently, and Grafana renders them in real‑time dashboards. The setup is lightweight enough for small‑to‑medium services yet scales by adding more scrape targets or remote storage back‑ends as your infrastructure grows. Regularly review alert rules and expand your dashboards to cover application‑specific metrics, and you’ll stay ahead of performance bottlenecks before they impact users.

Tags:

Grafana dashboardLinux server metricsPrometheus monitoring
Author

Devnix

Follow Me
Other Articles
Previous

How to Harden a Linux Server with UFW and Rate‑Limiting Rules

Next

Automating Reliable Daily Backups on a Linux Cloud VPS with rsync and cron

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • WordPress Image Optimization: Native Settings vs Plugins vs CDN vs Server‑Side Solutions
  • Understanding Database Connection Pooling in Cloud Deployments
  • Odoo User Access Rights Audit Checklist – Secure Your ERP Without Over‑Privileging
  • WordPress Caching Showdown: Built‑In, Plugins, Server‑Side, or CDN?
  • Cloud VPS vs Managed WordPress Hosting vs Static Site Hosting: Which Platform Delivers the Best Uptime and Security for Small‑Business Websites?

Archives

  • June 2026
  • May 2026

Categories

  • Backup Strategies
  • Cloud VPS Performance
  • Docker Compose Deployment
  • Odoo Email Configuration
  • Odoo Inventory
  • Odoo Invoicing
  • Odoo Multi-Company Configuration
  • Odoo Subscriptions
  • Odoo User Management
  • Server Security
  • WordPress Migration
  • WordPress Performance Optimization

About Devnix Blog

A forward-thinking tech publication covering software engineering, cloud infrastructure, and modern digital transformation. Built for developers and tech enthusiasts.

Our Services

  • Cloud VPS Hosting
  • Managed ERP Solutions
  • DevOps Automation
  • Server Security & Optimization

Partners

  • Odoo Stack
  • Odoo Backup
  • Devnix Solutions
Copyright 2026 — Devnix Blog. All rights reserved. Devnix Solutions