Why Server Health Monitoring Matters for VPS Hosting
Your Ubuntu VPS runs 24/7, handling website traffic, database queries, and application requests. Without proper server health monitoring, you won't know about memory leaks, disk space issues, or CPU spikes until your sites go down.
This tutorial walks you through setting up comprehensive monitoring with Prometheus and Grafana. You'll track system metrics, configure alerts, and build dashboards that show exactly what's happening on your server.
We'll use open-source tools that work reliably on Hostperl VPS hosting environments. The entire setup takes about 45 minutes and gives you production-grade monitoring capabilities.
Prerequisites and System Requirements
You need an Ubuntu 22.04 or 24.04 VPS with at least 2GB RAM and 20GB disk space. The monitoring stack itself uses about 500MB of memory when properly configured.
Make sure you have sudo access and a domain name or subdomain pointing to your server. We'll set up SSL certificates for secure access to your monitoring dashboards.
Update your system packages first:
sudo apt update && sudo apt upgrade -y
sudo apt install wget curl git -y
Install and Configure Prometheus Server
Prometheus collects and stores time-series metrics from your server. Download the latest version and create a dedicated user account:
cd /tmp
wget https://github.com/prometheus/prometheus/releases/download/v2.48.0/prometheus-2.48.0.linux-amd64.tar.gz
tar xvf prometheus-2.48.0.linux-amd64.tar.gz
Create the prometheus user and required directories:
sudo useradd --no-create-home --shell /bin/false prometheus
sudo mkdir /etc/prometheus /var/lib/prometheus
sudo chown prometheus:prometheus /etc/prometheus /var/lib/prometheus
Copy the binaries and configuration files:
sudo cp prometheus-2.48.0.linux-amd64/prometheus /usr/local/bin/
sudo cp prometheus-2.48.0.linux-amd64/promtool /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/prometheus /usr/local/bin/promtool
sudo cp -r prometheus-2.48.0.linux-amd64/consoles /etc/prometheus
sudo cp -r prometheus-2.48.0.linux-amd64/console_libraries /etc/prometheus
sudo chown -R prometheus:prometheus /etc/prometheus/consoles /etc/prometheus/console_libraries
Create the main Prometheus configuration file at /etc/prometheus/prometheus.yml:
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
- "alert_rules.yml"
alerting:
alertmanagers:
- static_configs:
- targets:
- localhost:9093
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090']
- job_name: 'node-exporter'
static_configs:
- targets: ['localhost:9100']
Set the correct ownership:
sudo chown prometheus:prometheus /etc/prometheus/prometheus.yml
Install Node Exporter for System Metrics
Node Exporter provides detailed system metrics like CPU usage, memory consumption, and disk I/O. Download and install it:
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.7.0/node_exporter-1.7.0.linux-amd64.tar.gz
tar xvf node_exporter-1.7.0.linux-amd64.tar.gz
sudo cp node_exporter-1.7.0.linux-amd64/node_exporter /usr/local/bin/
sudo chown prometheus:prometheus /usr/local/bin/node_exporter
Create a systemd service file for Node Exporter at /etc/systemd/system/node_exporter.service:
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
sudo systemctl status node_exporter
Configure Prometheus System Service
Create a systemd service file for Prometheus at /etc/systemd/system/prometheus.service:
[Unit]
Description=Prometheus
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 \
--web.listen-address=0.0.0.0:9090 \
--web.enable-lifecycle
[Install]
WantedBy=multi-user.target
Start Prometheus and verify it's collecting metrics:
sudo systemctl daemon-reload
sudo systemctl enable prometheus
sudo systemctl start prometheus
sudo systemctl status prometheus
Check that Prometheus is scraping Node Exporter by visiting http://your-server-ip:9090/targets. Both targets should show as "UP".
Install and Configure Grafana for Dashboards
Grafana creates visual dashboards from Prometheus data. Install the official repository and package:
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
Enable and start Grafana:
sudo systemctl enable grafana-server
sudo systemctl start grafana-server
sudo systemctl status grafana-server
Access Grafana at http://your-server-ip:3000. The default login is admin/admin. Change this password immediately.
Add Prometheus as a data source:
- Click "Add data source"
- Select "Prometheus"
- Set URL to
http://localhost:9090 - Click "Save & Test"
Create Essential Dashboards
Import pre-built dashboards that cover the most important metrics. Go to Dashboards → Import and use these dashboard IDs:
- Node Exporter Full (ID: 1860) - Comprehensive system overview
- Node Exporter Server Metrics (ID: 405) - Focused server view
- System Overview (ID: 3662) - Clean, readable layout
These dashboards show CPU usage, memory consumption, disk I/O, network traffic, and filesystem usage. They update in real-time and provide historical trend data.
Create a custom dashboard for critical alerts. Add panels for:
- Available disk space percentage
- Memory usage over time
- CPU load average (1m, 5m, 15m)
- Network connections and bandwidth
Set appropriate time ranges and refresh intervals based on your monitoring needs.
Set Up Critical Alert Rules
Create alert rules that notify you about server problems before they cause downtime. Add this content to /etc/prometheus/alert_rules.yml:
groups:
- name: server_alerts
rules:
- alert: HighCPUUsage
expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100) > 80
for: 2m
labels:
severity: warning
annotations:
summary: "High CPU usage detected"
description: "CPU usage is above 80% for more than 2 minutes"
- alert: HighMemoryUsage
expr: (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 < 10
for: 1m
labels:
severity: critical
annotations:
summary: "High memory usage detected"
description: "Available memory is below 10%"
- alert: DiskSpaceLow
expr: (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"}) * 100 < 15
for: 1m
labels:
severity: warning
annotations:
summary: "Low disk space on root filesystem"
description: "Root filesystem has less than 15% space remaining"
- alert: ServerDown
expr: up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Server is down"
description: "Server {{ $labels.instance }} is down"
Restart Prometheus to load the new alert rules:
sudo systemctl restart prometheus
Configure SSL and Secure Access
Install Nginx as a reverse proxy with SSL termination. This secures your monitoring dashboards:
sudo apt install nginx certbot python3-certbot-nginx -y
Create an Nginx configuration for Grafana at /etc/nginx/sites-available/monitoring:
server {
listen 80;
server_name monitoring.yourdomain.com;
location / {
proxy_pass http://127.0.0.1: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;
}
}
server {
listen 80;
server_name prometheus.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:9090;
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;
}
}
Enable the configuration and obtain SSL certificates:
sudo ln -s /etc/nginx/sites-available/monitoring /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
sudo certbot --nginx -d monitoring.yourdomain.com -d prometheus.yourdomain.com
Your monitoring setup now runs over HTTPS with automatically renewing SSL certificates.
Setting up comprehensive monitoring protects your hosting infrastructure from unexpected downtime. Hostperl VPS hosting includes monitoring-friendly configurations and fast NVMe storage that works perfectly with Prometheus and Grafana deployments.
Frequently Asked Questions
How much system resources does this monitoring setup use?
Prometheus typically uses 200-300MB RAM and minimal CPU. Grafana uses another 150-200MB RAM. Node Exporter has virtually no performance impact. The total overhead is less than 600MB on a properly configured system.
Can I monitor multiple servers from one Grafana instance?
Yes. Install Node Exporter on each server you want to monitor, then add their IP addresses to the Prometheus configuration scrape_configs section. One central monitoring server can track dozens of remote systems.
How long does Prometheus store historical data?
By default, Prometheus keeps 15 days of data. You can increase retention with the --storage.tsdb.retention.time flag in the systemd service file. For longer retention, consider using remote storage solutions like InfluxDB.
What should I do if alerts are too sensitive or missing important issues?
Adjust the thresholds in alert_rules.yml based on your server's normal operating patterns. Monitor for a few days to establish baselines, then fine-tune the CPU, memory, and disk space alert levels for your specific workload.
How do I backup my monitoring configuration and dashboards?
Back up /etc/prometheus/ directory for Prometheus configs and use Grafana's export feature to save dashboard JSON files. Store these in version control alongside your other server configurations for easy restoration.

