18/11/2026
Prometheus and Grafana Monitoring on One VPS
Your server is up, everything looks fine, then it fills the disk or dies. You find out when a customer calls. That's where Prometheus Grafana monitoring earns its keep.
Your server is up, everything looks fine, then it fills the disk or dies. You find out when a customer calls. That's where Prometheus Grafana monitoring earns its keep.
On the ITcorv team we usually put this stack on a single VPS: Prometheus scrapes metrics, Grafana shows them, Alertmanager tells you when something breaks. This post is that practical path on one server. Not a theory dump.
If you're still figuring out where Docker Compose stops and Kubernetes starts, see this post. If image pulls fail from Iran, use the same Docker Hub mirrors; we won't re-explain that here.
What is Prometheus and Grafana monitoring?
A few parts, each with one job:
- Prometheus: time-series DB and scraper. Every few seconds it hits the targets, pulls metrics, and keeps them. You query with PromQL. Default port
9090. - node_exporter: host metrics — CPU, RAM, disk, network. Port
9100. Without it, Prometheus mostly sees itself. - Grafana: dashboards. Reads from Prometheus and draws graphs. Port
3000. Default login isadmin/admin; change it right away. - Alertmanager: Prometheus fires the rule, Alertmanager sends it somewhere useful like Telegram or email. Port
9093.
Simple idea: exporter makes metrics → Prometheus stores them → Grafana shows them → if a threshold breaks, Alertmanager notifies you.
Sample config on one VPS
Assume a Linux server with Docker and Docker Compose. Everything under one folder, for example /opt/monitoring.
Image tags used in this post (stable releases late 2026):
prom/prometheus:v3.16.0prom/node-exporter:v1.10.2grafana/grafana:13.3.0prom/alertmanager:v0.34.2
If a tag moves on, update only these lines in compose.
Folder layout
/opt/monitoring/
docker-compose.yml
prometheus/
prometheus.yml
alerts.yml
alertmanager/
alertmanager.yml1) docker-compose.yml
We keep node_exporter on the Compose network (not network_mode: host) so Prometheus can scrape by service name: node-exporter:9100. With pid: host and a read-only host rootfs mount you get the host's real CPU, memory, disk and filesystem metrics. One exception: in this mode network metrics show the container's own interface, not the host's NICs. If you need host network traffic, run node-exporter with network_mode: host (see the node_exporter docs).
services:
prometheus:
image: prom/prometheus:v3.16.0
container_name: prometheus
restart: unless-stopped
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.enable-lifecycle'
volumes:
- ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./prometheus/alerts.yml:/etc/prometheus/alerts.yml:ro
- prometheus_data:/prometheus
ports:
- '127.0.0.1:9090:9090'
depends_on:
- node-exporter
- alertmanager
node-exporter:
image: prom/node-exporter:v1.10.2
container_name: node-exporter
restart: unless-stopped
pid: host
command:
- '--path.rootfs=/host'
volumes:
- '/:/host:ro,rslave'
# Port only on the Compose network; no need to publish it
grafana:
image: grafana/grafana:13.3.0
container_name: grafana
restart: unless-stopped
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=CHANGE_ME_NOW
volumes:
- grafana_data:/var/lib/grafana
ports:
- '127.0.0.1:3000:3000'
depends_on:
- prometheus
alertmanager:
image: prom/alertmanager:v0.34.2
container_name: alertmanager
restart: unless-stopped
volumes:
- ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml:ro
ports:
- '127.0.0.1:9093:9093'
volumes:
prometheus_data:
grafana_data:Ports are bound to 127.0.0.1. They are not open on the public internet. Reach them with an SSH tunnel or a reverse proxy behind VPN/Zero Trust. If you bind to 0.0.0.0, the whole world can see the UI.
2) prometheus/prometheus.yml
Target names must match Compose service names exactly. Inside the container, localhost is Prometheus itself, not node_exporter.
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
rule_files:
- /etc/prometheus/alerts.yml
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ['localhost:9090']
- job_name: node
static_configs:
- targets: ['node-exporter:9100']3) prometheus/alerts.yml
A simple rule: target down for one minute.
groups:
- name: host
rules:
- alert: InstanceDown
expr: up == 0
for: 1m
labels:
severity: critical
annotations:
summary: "Target {{ $labels.instance }} is down"
description: "Job {{ $labels.job }} for more than 1 minute."
- alert: HighCPU
expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 90
for: 5m
labels:
severity: warning
annotations:
summary: "CPU high on {{ $labels.instance }}"4) alertmanager/alertmanager.yml (optional but useful)
Start with logging so you can see alerts land. Add a Telegram webhook or email later.
route:
receiver: default
group_by: ['alertname', 'instance']
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: default
# Add webhook_configs or email_configs later
# Empty is fine; alerts still show in the Alertmanager UIAn empty receiver still works; you can see alerts at http://127.0.0.1:9093 even if nothing is forwarded yet.
Bring it up
cd /opt/monitoring
docker compose up -d
docker compose psTesting
1) node_exporter metrics:
From the host, through the Compose network:
docker compose exec prometheus wget -qO- http://node-exporter:9100/metrics | headYou should see lines like node_cpu_seconds_total.
2) Prometheus targets:
Open http://127.0.0.1:9090/targets over your tunnel. Both jobs prometheus and node should be UP.
If node is red, the service name in prometheus.yml usually doesn't match Compose, or node_exporter isn't up yet.
3) A few PromQL queries:
In Graph, try:
rate(node_cpu_seconds_total{mode="system"}[1m])node_filesystem_avail_bytesrate(node_network_receive_bytes_total[1m])If you get numbers, scraping works.
4) Grafana:
Open http://127.0.0.1:3000. Log in with the user/password from Compose. Change the default password immediately.
Connections → Data sources → Add → Prometheus. URL:
http://prometheus:9090Save & test should go green. Then import a Node Exporter dashboard from Grafana.com (the well-known ID 1860 works) or build a panel with the PromQL above.
5) Fire a test alert:
Easiest path: stop node_exporter for a minute.
docker compose stop node-exporterAfter about a minute, Prometheus → Alerts should show InstanceDown firing. It should also appear in Alertmanager. Then start it again:
docker compose start node-exporterTips
- Service name = scrape target. Inside the Prometheus container,
localhostis Prometheus. For node_exporter usenode-exporter:9100. - Don't publish ports publicly. Prefer
127.0.0.1or a reverse proxy with auth. An open monitoring UI is a map of your servers. - Grafana password. Set a strong
GF_SECURITY_ADMIN_PASSWORDbefore the firstup; it only applies whengrafana_datais empty. Later, change it in the UI. - Prometheus disk. Metrics take space. Add something like
--storage.tsdb.retention.time=15dlater if the disk is small. - More hosts. Run node_exporter on each machine and add their addresses to
static_configs. Or move to service discovery later. - Logs. You have CPU and RAM; app logs are separate. Next step is usually Loki. This post doesn't set logs up; just know the gap is there.
- GitOps / CI. If you keep monitoring config in git and deploy it from a pipeline, the path looks like GitLab CI to deploy. The wider DevOps path is in this roadmap.
- Pin tags. Don't use
latest. When you want an upgrade, change the tag on purpose.
FAQ
Why is the node target red?
Usually the service name in prometheus.yml doesn't match Compose, the container hasn't finished starting, or you're scraping localhost:9100 from inside Prometheus. Use node-exporter:9100.
Do I need Alertmanager?
Not for graphs. For knowing at 3 a.m. that a host died, yes. Without alerts you only notice when you look.
Images won't pull on a server in Iran. What then?
Use the same mirror approach from Docker Hub in Iran. Monitoring config stays the same; only the registry changes.
Is this stack enough for production?
For one VPS or a few small hosts, yes, it's a solid start. When the fleet and the team grow, you add HA, remote write and logs with Loki.
The ITcorv team runs Prometheus/Grafana/Loki monitoring as part of our DevOps services, with 24/7 support. For a consultation, reach out from this page.