
Dashboards earn their keep when they live close to the systems you run. When a site slows down, you want CPU steal time, disk latency, and Nginx/PHP errors in one view. You also want that view without shipping sensitive metrics into someone else’s SaaS.
This post walks through how to install Grafana on a VPS as a practical, self-hosted alternative. We’ll use a small Prometheus stack that runs on real infrastructure.
You don’t need to become an observability specialist. You need a setup you can live with: CPU, RAM, disk, network, and service metrics. You also need the day‑2 basics that matter in 2026—TLS at the edge, backups you can restore, and upgrades that don’t trash dashboards mid-week.
Why install Grafana on a VPS instead of using hosted dashboards
Hosted Grafana (and similar monitoring SaaS products) is convenient. It’s also a trade: recurring per-user/per-metric costs, extra egress, and the overhead of shipping internal metrics off-box.
If you run multiple small VPS nodes—or you simply prefer keeping operational data in-house—self-hosting is often the calmer option.
- You keep metrics on your infrastructure. That matters when dashboards include internal IPs, DB hostnames, or endpoint-level latency.
- You reduce dependencies. If the route to a SaaS provider degrades, your dashboards still load locally.
- Your cost scales predictably. A modest VPS can monitor several nodes if you size retention and storage sensibly.
If you’d rather not babysit the OS and Docker layer, this setup pairs well with managed VPS hosting. You keep control of Grafana while offloading kernel updates, base hardening, and routine server maintenance.
Open-source spotlight: Grafana + Prometheus (what it solves, who it’s for)
Grafana is an open-source visualization and alerting platform. It connects to data sources—Prometheus, PostgreSQL, Loki, Elasticsearch, and many others. It turns time-series data into dashboards and alerts.
Grafana ships under the AGPLv3 license (Grafana Labs also sells enterprise features under commercial terms).
Prometheus is an open-source metrics database and scraper (Apache License 2.0). It polls HTTP endpoints (usually /metrics) on a schedule. It stores results locally and exposes them via PromQL.
For server and app metrics on your own infrastructure, Grafana + Prometheus is still the clean baseline.
This stack is for:
- Operators running WordPress, WooCommerce, PHP apps, Node.js APIs, or small SaaS workloads who want saturation signals (CPU, memory, disk IO)—not just “up/down”.
- Teams with multiple VPS nodes who want one place to catch regressions after deployments.
- Anyone who prefers “private by default” for operational data.
If you also need external “is it down?” checks, add uptime monitoring later. HostMyCode has a separate guide that fits this approach: Deploy Grafana on a VPS With Docker, TLS, and Backups. (This post stays focused on the Grafana + Prometheus stack and the operational work that follows.)
Hosted Grafana vs self-hosted Grafana: a quick reality check
This isn’t “good vs bad.” It’s a choice about which responsibilities you want.
- Hosted Grafana: quick start and less maintenance, but you pay ongoing fees and ship metrics out. Works well when you already centralize everything in the cloud.
- Self-hosted Grafana: you own updates, backups, and TLS, but you keep full control and avoid pricing surprises as you add nodes.
If your workloads already live on your own VPS or dedicated server, self-hosting often feels appropriately “close to the box.” You can also right-size it. Start small, then extend retention or storage once you have real usage data.
What you’ll run on your VPS (and what it costs in resources)
A practical baseline stack looks like this:
- Grafana (dashboards, alerts)
- Prometheus (metrics storage + scraping)
- node_exporter on each Linux server you want to monitor (CPU/RAM/disk/network)
Resource needs come down to scrape interval, number of targets, metric cardinality, and retention. As a starting point:
- Small (1–3 servers): 1 vCPU, 2 GB RAM, 25–40 GB NVMe. 7–15 days retention is usually enough.
- Medium (5–15 servers): 2 vCPU, 4 GB RAM, 80–160 GB NVMe. Consider 15–30 days retention.
- Larger (15+ servers or heavy app metrics): 4 vCPU, 8 GB RAM, fast NVMe, and a plan for long-term storage (remote_write or downsampling later).
If you’re monitoring customer sites or revenue-driving apps, put this stack on a VPS separate from your web tier. During an incident, the web box may thrash. Your monitoring should still be usable.
A HostMyCode VPS makes that separation easy without committing to dedicated hardware.
Deploy the stack with Docker Compose (Grafana + Prometheus)
Compose keeps things explicit. You choose image tags, define persistent volumes, and control upgrades. That predictability matters more than initial setup speed.
On Ubuntu 24.04 LTS / Debian 12, you’d typically install Docker Engine and the Compose plugin first. Then create a working directory:
sudo mkdir -p /opt/monitoring
sudo chown -R $USER:$USER /opt/monitoring
cd /opt/monitoring
Example docker-compose.yml (trimmed to the essentials):
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=15d
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
restart: unless-stopped
networks:
- monitoring
grafana:
image: grafana/grafana-oss:latest
container_name: grafana
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=change-me-now
- GF_USERS_ALLOW_SIGN_UP=false
volumes:
- grafana-data:/var/lib/grafana
restart: unless-stopped
networks:
- monitoring
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
pid: host
command:
- --path.rootfs=/host
volumes:
- /:/host:ro,rslave
restart: unless-stopped
networks:
- monitoring
networks:
monitoring:
volumes:
prometheus-data:
grafana-data:
Prometheus config at /opt/monitoring/prometheus/prometheus.yml:
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']
- job_name: 'node'
static_configs:
- targets: ['node-exporter:9100']
# Add remote servers as 'IP:9100' once node_exporter is installed there.
Bring it up:
docker compose up -d
docker compose ps
Two practical notes:
- Don’t expose Grafana or Prometheus directly on the public internet. Put them behind a reverse proxy, and firewall them to localhost or a private network.
- Change the admin password immediately and consider disabling admin user creation via provisioning later.
Reverse proxy + HTTPS (Nginx example) for a clean public endpoint
Keep Grafana on an internal Docker network. Publish only Nginx on ports 80/443. You get TLS termination, request logs, and one place for security headers.
Assume:
- Domain:
grafana.example.com - Nginx on the VPS host
- Grafana container reachable on the Docker network
Create an Nginx server block (Ubuntu/Debian): /etc/nginx/sites-available/grafana.conf
server {
listen 80;
server_name grafana.example.com;
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2;
server_name grafana.example.com;
ssl_certificate /etc/letsencrypt/live/grafana.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/grafana.example.com/privkey.pem;
# Basic hardening headers
add_header X-Content-Type-Options nosniff;
add_header X-Frame-Options SAMEORIGIN;
add_header Referrer-Policy no-referrer-when-downgrade;
location / {
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;
proxy_pass http://127.0.0.1:3000;
}
}
But wait—our Grafana container isn’t published on 127.0.0.1:3000 yet. You have two common options:
- Publish Grafana only to localhost by adding to the Grafana service:
ports: - "127.0.0.1:3000:3000" - Use a Docker-aware reverse proxy (Caddy, Traefik, or Nginx Proxy Manager). This can simplify multi-app routing.
For Let’s Encrypt certificates, you can use Certbot, or use Caddy if you prefer automatic certificate handling. If you manage multiple subdomains and want a wildcard certificate, HostMyCode’s DNS-based approach is a solid pattern: Add Let’s Encrypt Wildcard SSL With Caddy and DNS.
If you don’t want Grafana publicly reachable at all, put it behind a private access layer. Cloudflare Tunnel is one option for restricting admin tools without opening inbound ports: Set Up Cloudflare Tunnel on a VPS for Private Admin.
Getting CPU, RAM, disk, and network metrics from your servers
node_exporter is the standard source for Linux host metrics. Run it (as shown) on the monitoring VPS itself. Then deploy it to each server you want to track.
Two deployment patterns work well:
- Docker on each node: fast to roll out, consistent configs, easy updates. Downside: you now depend on Docker everywhere.
- Systemd binary install: lightweight and dependable on a plain VPS. Downside: you’ll handle upgrades yourself.
Whichever route you pick, treat port 9100 as internal-only. Lock it down with UFW/firewalld or security groups so only the Prometheus server can reach it. Public exporters are an avoidable foot-gun.
Once exporters are reachable, add targets to prometheus.yml:
- job_name: 'node-remote'
static_configs:
- targets:
- '10.0.0.10:9100'
- '10.0.0.11:9100'
In Grafana, add Prometheus as a data source (Configuration → Data sources). Then import a node_exporter dashboard from Grafana’s library. Within a few minutes, you’ll have a credible “is this server healthy?” view.
Backups that actually matter: Grafana state and Prometheus data
Backups are where many self-hosted monitoring stacks quietly fall apart. The fix is simple. Back up what’s painful to recreate, and be honest about what’s disposable.
- Grafana: the database inside
/var/lib/grafana(dashboards, users, API keys), plus provisioning files if you use them. - Prometheus: the TSDB in
/prometheus(large) is valuable, but many teams treat it as “rebuildable” if losing history is acceptable.
A workable compromise for many operators:
- Back up Grafana daily.
- Back up Prometheus weekly (or not at all), depending on retention requirements and storage budget.
If you already do file-level offsite backups (Borg, Restic, rsync to object storage), include your Docker volumes directory or your named volume backups.
For Docker named volumes, a common approach is a short-lived container that archives the volume:
# Grafana volume backup
sudo docker run --rm \
-v grafana-data:/data \
-v /opt/backups:/backup \
alpine sh -c "tar -czf /backup/grafana-data-$(date +%F).tgz -C /data ."
Do the same for Prometheus if you actually need that history. Then run a restore test at least once. If you’ve never restored it, it’s not a backup—it’s a hope.
If you want a repeatable way to think about backup verification, the same “tested restore” rule applies across stacks. For databases, this HostMyCode guide is a good template: Set Up Automatic MySQL Backups With Tested Restores.
Updates without breaking your dashboards
Grafana and Prometheus ship updates constantly. The goal isn’t to chase every release. It’s to upgrade on your terms.
- Pin image tags instead of running
:latestin production. Update intentionally. - Back up Grafana volume before upgrades.
- Read breaking change notes for major versions (Grafana and Prometheus both publish them).
A simple update routine for Compose:
cd /opt/monitoring
docker compose pull
docker compose up -d
docker image prune
After upgrading, check:
- Grafana login works and dashboards load
- Prometheus targets are “UP”
- Disk usage hasn’t jumped unexpectedly
Operational pitfalls you’ll want to avoid
Most Grafana-on-a-VPS failures are boring. That’s good news. Boring usually means predictable, measurable, and fixable.
- Disk fills up. Prometheus retention and cardinality will eat storage. Start with 15 days, then adjust. Watch
df -hweekly until you understand the growth curve. - Exporter ports left public. Keep
9100private. Same goes for Prometheus9090. - Grafana admin credentials never rotated. Use a strong password, create named users, and keep signup disabled.
- TLS is skipped “for later”. Dashboards often expose internal hostnames and paths. Put HTTPS in front from day one.
If you’re debugging reverse proxy behavior, Nginx problems show up quickly. 413/502 are common when uploads fail or upstream routing is wrong. These references help: Nginx 413 Request Entity Too Large Fix On VPS and Nginx 502 Bad Gateway Fix on Ubuntu VPS.
Where this fits in a real hosting setup (WordPress, apps, agencies)
If you run WordPress or WooCommerce, Grafana complements app-level monitoring nicely. You can separate “WordPress is slow” from “the VPS is saturated” in a couple of clicks.
Pair that with server-side caching, sane PHP-FPM settings, and (when it makes sense) Redis object caching.
For agencies, centralizing metrics matters even more. One monitoring VPS can track multiple client nodes. If you separate customer environments, self-hosted Grafana also gives you clean tenancy controls: folders, permissions, and separate organizations when you need harder boundaries.
For high-traffic apps where performance swings cost money, plan for faster storage and steadier CPU. At that point, upgrading the monitoring node isn’t vanity; it’s stability.
HostMyCode options like dedicated servers usually make sense when predictability matters more than flexibility.
Summary: a self-hosted Grafana stack you can operate
If you want dashboards that reflect what your infrastructure is actually doing, self-hosting is hard to beat. Install Grafana with Prometheus, terminate HTTPS properly, keep exporter ports private, and back up Grafana state so dashboards survive mistakes and upgrades.
If you want this running on stable infrastructure with room to grow, start with a HostMyCode VPS. Scale only when retention and target count justify it.
If you want the benefits of install Grafana on a VPS without owning the base OS chores, managed VPS hosting is the straightforward path.
Your monitoring node should stay responsive when everything else is on fire. A dedicated HostMyCode VPS gives you predictable CPU and NVMe for retention, and managed VPS hosting helps if you want security updates, patching, and routine server care handled for you.
FAQ
Should I run Grafana on the same VPS as my website?
You can for small setups, but separation is safer. If your site spikes CPU or disk IO during an incident, Grafana stays responsive on its own VPS.
Do I need Prometheus, or can Grafana work alone?
Grafana needs a data source. Prometheus is the common choice for server metrics because it scrapes exporters directly and keeps querying fast and local.
What’s the minimum you should back up?
Back up Grafana’s data directory (the grafana-data volume). That’s where dashboards and configuration live. Prometheus history is optional depending on how much you care about long-term trends.
How do I keep Grafana private but still reachable?
Put it behind HTTPS and restrict access: IP allowlists, HTTP auth, VPN, or a tunnel solution. If you want a tunnel-based approach for admin tools, see this Cloudflare Tunnel guide.
What’s the most common reason Prometheus disk usage grows too fast?
High-cardinality metrics (too many label combinations) and long retention. Start with 7–15 days retention and be selective about scraping application metrics until you understand growth.