A 2GB VPS can run a useful monitoring stack if you keep it lean. This prometheus grafana 2gb vps guide walks through the full setup on Ubuntu 24.04 with Docker: Prometheus for metrics, node_exporter for host data, and Grafana for dashboards. You will end with a working dashboard, a 7-day retention window, and memory limits that leave room for your other services. The whole stack fits on one small server, and you can finish the install in under an hour.
Prometheus collects numbers, Grafana turns them into charts, and node_exporter reports CPU, memory, disk, and network figures to Prometheus every 15 seconds.
What you need before you start
Use a VPS with 2GB of RAM, 1 or 2 vCPUs, and at least 20GB of free disk. Ubuntu 22.04 or 24.04 works for every command below. You also need a non-root user with sudo, SSH access, and a domain or subdomain if you plan to open Grafana to the web. Keep Grafana closed to the public internet until the reverse proxy and login are in place.
Install Docker and set up the folders
Docker Compose keeps this stack in one file and makes restarts predictable. If Docker is not on the server yet, install it first and follow the step-by-step Docker Compose install guide for Ubuntu 24.04. Confirm the install with docker --version and docker compose version before you go on.
Create a folder for the stack and a subfolder for the Prometheus config:
mkdir -p ~/monitoring/prometheus
cd ~/monitoring
Write the Prometheus config
Prometheus needs a config file that tells it where to scrape metrics. Create prometheus/prometheus.yml with two scrape jobs: one for Prometheus itself and one for node_exporter on the host.
global:
scrape_interval: 15s
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: node
static_configs:
- targets: ['node-exporter:9100']
A 15-second scrape interval gives smooth graphs without hammering a small CPU. A 5-second interval doubles the samples Prometheus has to store, and on a 2GB VPS that cost shows up fast.
Add node_exporter and start the stack
Now write the compose file. This prometheus grafana setup uses three containers: Prometheus, Grafana, and node_exporter. Each one gets a memory limit so a runaway container cannot starve the rest of the server.
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
- prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=7d'
ports:
- '127.0.0.1:9090:9090'
mem_limit: 512m
node-exporter:
image: prom/node-exporter:latest
container_name: node-exporter
restart: unless-stopped
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.sysfs=/host/sys'
- '--path.rootfs=/rootfs'
ports:
- '127.0.0.1:9100:9100'
mem_limit: 128m
grafana:
image: grafana/grafana:latest
container_name: grafana
restart: unless-stopped
volumes:
- grafana-data:/var/lib/grafana
ports:
- '127.0.0.1:3000:3000'
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=change-this-password
mem_limit: 512m
volumes:
prometheus-data:
grafana-data:
Change the Grafana admin password in the compose file first. Ports bind to 127.0.0.1, so nothing is reachable from the internet until you add a reverse proxy.
docker compose up -d
docker compose ps
Check that all three containers show as running. In the Prometheus web UI, go to Status, then Targets. Both jobs should show as Up.
Log in to Grafana and build your first dashboard
Open Grafana on port 3000 and log in with the admin user and password from the compose file. Grafana asks you to set a new admin password on first login.
Add Prometheus as a data source. Go to Connections, then Data sources, then Add data source, and pick Prometheus. Set the URL to http://prometheus:9090, because Grafana runs in the same Docker network and can reach Prometheus by its service name. Click Save and test.
Now build a first dashboard for grafana dashboard vps monitoring. Create a new dashboard and add panels with these queries:
- CPU usage:
100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) - Memory usage:
(1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100 - Disk usage:
100 - ((node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"}) * 100) - Load average:
node_load1
Set each panel to a 5-minute rate window. Save the dashboard as VPS Overview. You now have the four numbers that answer most late-night questions: is the CPU busy, is memory full, is the disk filling up, and is the load climbing.
Tune Prometheus Grafana 2GB VPS retention and memory
Default Prometheus settings assume a bigger server. On a 2GB VPS, three settings matter most: retention time, scrape interval, and container memory limits. The compose file above already sets retention to 7 days and caps Prometheus at 512MB and Grafana at 512MB. Seven days is enough to spot a weekly pattern without letting the time-series database grow without bound.
If memory pressure shows up, work through the limits in this order. First, drop retention to 3 days by changing the flag to --storage.tsdb.retention.time=3d and restarting Prometheus. Second, raise the scrape interval to 30 seconds in prometheus.yml. Third, lower the Grafana limit to 384MB. Do not remove the limits entirely. Limits are what stop one container from taking memory your website or database needs. For a deeper look at capping containers, see the guide to limiting Docker container memory and CPU usage.
Put Grafana behind a reverse proxy with basic auth
Do not leave Grafana on port 3000 open to the internet. Put it behind Nginx with HTTPS and keep the Grafana login as the second layer. Point a subdomain such as grafana.example.com at the VPS, get a certificate with Certbot, and proxy to http://127.0.0.1:3000.
listen 443 ssl;
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;
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;
}
}
If you need the full walkthrough, the guide on configuring Nginx as a reverse proxy for Docker containers covers the server block, headers, and HTTPS step by step. After the proxy works, close port 3000 in the firewall and confirm the direct port no longer answers from outside:
sudo ufw deny 3000/tcp
sudo ufw deny 9090/tcp
sudo ufw status
For a small team, add HTTP basic auth in Nginx as an extra gate in front of the Grafana login. For a single admin, the Grafana login plus HTTPS is enough. Either way, never run Grafana with the default admin password, and never expose Prometheus port 9090. Prometheus has no login by default, so anyone who reaches it can read your metrics and your target list.
Check it works and fix common problems
Run through this list after the first day. Open the VPS Overview dashboard and confirm all four panels draw data. Open Prometheus Targets and confirm both jobs are Up. Check container memory with docker stats and confirm Prometheus stays under its 512MB cap. Restart the stack once with docker compose restart and confirm the dashboard still loads, which proves the volumes kept the data.
Common problems have short fixes. If Grafana shows no data, check the data source URL first: it must be http://prometheus:9090, not localhost, because localhost inside the Grafana container is Grafana itself. If node_exporter shows as down, restart it and check the container logs for a mount error. If Prometheus restarts in a loop, check disk space first, then look for a YAML error in prometheus.yml, since one bad indent stops the whole service.
FAQ
Can Prometheus and Grafana run on a 1GB VPS?
They can start, but 1GB leaves little room for anything else. The node exporter prometheus setup in this guide assumes 2GB, with 512MB for Prometheus and 512MB for Grafana. On 1GB, drop retention to 3 days, raise the scrape interval to 30 seconds, and run nothing else heavy on the same server.
How long should I keep Prometheus data?
Seven days suits most small servers. It covers a full week of patterns and keeps disk use predictable. Keep 30 days only if you have the disk space and a reason to compare month to month. This is the prometheus retention low ram trade-off in one line: longer history costs disk and memory, so keep the shortest window that still answers your questions.
Do I need node_exporter on every server I monitor?
Yes, if you want host numbers from that server. Install node_exporter on each VPS, add a scrape job for each one in prometheus.yml, and label the jobs by server name. One Prometheus server can collect from several small VPSs without much extra memory.
Is Grafana enough on its own for uptime checks?
Grafana shows metrics, but it does not ping your site from outside. Pair it with an external uptime checker so you get an alert when the whole VPS goes down, because a dead server cannot alert you about itself.
A prometheus grafana 2gb vps stack will not fix a slow server by itself. It shows you where the load comes from, which is the part that lets you fix the right thing. Start with the four panels above, keep retention short, keep the ports closed, and check the dashboard once a day for the first week.