Setting Up Infrastructure Monitoring with Grafana & Prometheus

Why Infrastructure Monitoring Matters

If you're running production workloads on a VPS or dedicated server, monitoring isn't optional โ€” it's the difference between catching a problem before it affects users and discovering it via a customer complaint. In the UK hosting market, where latency expectations are tight and uptime is critical, proper monitoring is essential.

This guide walks through setting up a complete monitoring stack using Prometheus for metrics collection and Grafana for visualisation. We use this exact stack across our own infrastructure at Hostingowy.

Architecture Overview

The Prometheus + Grafana stack consists of several components:

  • Prometheus Server โ€” scrapes and stores time-series metrics
  • Node Exporter โ€” exposes system metrics (CPU, memory, disk, network)
  • Grafana โ€” dashboard and alerting frontend
  • Alertmanager โ€” handles alert routing (email, Slack, PagerDuty)
  • Additional Exporters โ€” MySQL, Nginx, Redis, PostgreSQL, etc.

Step 1: Installing Prometheus

We deploy Prometheus on Ubuntu 22.04 LTS. Here's the installation process:

# Create prometheus user
sudo useradd --no-create-home --shell /bin/false prometheus

# Download latest 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
cd prometheus-2.53.0.linux-amd64

# Install binaries
sudo cp prometheus promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool

# Create config and data directories
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo cp prometheus.yml /etc/prometheus/
sudo cp consoles/ console_libraries/ /etc/prometheus/
sudo chown -R prometheus:prometheus /etc/prometheus /var/lib/prometheus

Prometheus Configuration

Here's a production-ready prometheus.yml configuration:

global:
  scrape_interval: 15s
  evaluation_interval: 15s
  external_labels:
    environment: 'production'
    region: 'uk-london'

scrape_configs:
  - job_name: 'node'
    static_configs:
      - targets:
        - 'web01.hostingowy.local:9100'
        - 'db01.hostingowy.local:9100'
        - 'monitor.hostingowy.local:9100'
    relabel_configs:
      - source_labels: [__address__]
        regex: '([^:]+).*'
        target_label: instance

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

  - job_name: 'nginx'
    static_configs:
      - targets: ['web01.hostingowy.local:9113']

alerting:
  alertmanagers:
    - static_configs:
        - targets: ['localhost:9093']

Step 2: Node Exporter Setup

Node Exporter provides system-level metrics. Install on every server you want to monitor:

# Download and install
wget https://github.com/prometheus/node_exporter/releases/download/v1.8.1/node_exporter-1.8.1.linux-amd64.tar.gz
tar xvf node_exporter-1.8.1.linux-amd64.tar.gz
sudo cp node_exporter-1.8.1.linux-amd64/node_exporter /usr/local/bin/
sudo useradd --no-create-home --shell /bin/false node_exporter

# Create systemd service
sudo tee /etc/systemd/system/node_exporter.service << 'EOF'
[Unit]
Description=Node Exporter
After=network.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter \
  --collector.systemd \
  --collector.textfile.directory=/var/lib/node_exporter/textfile_collector

[Install]
WantedBy=multi-user.target
EOF

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

Step 3: Grafana Installation

# Add Grafana repository
sudo apt-get 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-get update
sudo apt-get install -y grafana

# Configure Grafana
sudo tee -a /etc/grafana/grafana.ini << 'EOF'
[server]
domain = monitor.hostingowy.com
root_url = https://monitor.hostingowy.com

[auth.anonymous]
enabled = false

[security]
admin_user = admin

[alerting]
enabled = true
EOF

sudo systemctl enable --now grafana-server

Step 4: Adding Prometheus as a Data Source in Grafana

In the Grafana UI (http://your-server:3000, default admin/admin):

  1. Go to Configuration > Data Sources
  2. Click "Add data source" and select Prometheus
  3. Set URL to http://localhost:9090
  4. Click "Save & Test" โ€” you should see "Data source is working"

Step 5: Essential Dashboards

Here are the Grafana dashboard IDs we recommend for infrastructure monitoring:

  • Node Exporter Full (ID: 1860) โ€” comprehensive system metrics
  • 1 Node Dashboard (ID: 11074) โ€” single-server overview
  • Prometheus 2.0 Stats (ID: 3662) โ€” Prometheus performance
  • MySQL Overview (ID: 7362) โ€” database metrics
  • Nginx (ID: 9614) โ€” web server metrics

Step 6: Alerting Rules

Here are the critical alerting rules we use in production:

groups:
  - name: host_alerts
    rules:
      - alert: HighCPUUsage
        expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80
        for: 10m
        annotations:
          summary: "CPU usage above 80% on {{ $labels.instance }}"
          
      - alert: DiskSpaceLow
        expr: (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"}) * 100 < 15
        for: 5m
        annotations:
          summary: "Disk space below 15% on {{ $labels.instance }}"
          
      - alert: HighMemoryUsage
        expr: (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 > 90
        for: 5m
        annotations:
          summary: "Memory usage above 90% on {{ $labels.instance }}"
          
      - alert: NodeDown
        expr: up == 0
        for: 5m
        annotations:
          summary: "Instance {{ $labels.instance }} has been down for 5 minutes"

Monitoring at Hostingowy

Every Hostingowy VPS and dedicated server comes with free access to our Grafana + Prometheus monitoring stack. You get:

  • Pre-configured dashboards for CPU, memory, disk, and network
  • Bandwidth usage tracking
  • Disk I/O performance metrics
  • Uptime monitoring with 5-minute granularity
  • Alerting for resource exhaustion

This is included at no extra cost โ€” unlike providers that charge $15+/month per instance for basic monitoring.

Conclusion

Prometheus and Grafana provide enterprise-grade monitoring at zero software cost. The investment is in setup time and the server to run it on. For most teams, the stack pays for itself in reduced downtime and faster incident response within the first month.

Whether you're running a single VPS or a fleet of dedicated servers, monitoring is the foundation of reliable infrastructure. Start with the basics โ€” CPU, memory, disk, network โ€” and layer on application-specific metrics as you grow.

Get Free Monitoring with Every VPS

Every Hostingowy plan includes free Grafana + Prometheus monitoring. European data centres (Poland), NVMe storage, real UK engineers.

Deploy Your VPS โ†’

First month free with code LAUNCH100

Hostingowy Engineering
Infrastructure Team
๐Ÿš€

The Hostingowy Engineering Digest

Get monthly deep-dives on UK VPS hosting, infrastructure benchmarks, DevOps tooling, and cloud cost optimisation. Built by engineers, for engineers.

2 issues sent ยท 7 subscribers ยท No spam, ever

No spam. Unsubscribe anytime. Read our Privacy Policy.