TutorialsAugust 4, 20264 min read

How to Self-Host Grafana and Prometheus for Monitoring

The classic open-source monitoring stack. Install Prometheus and Grafana on a VPS with Docker, collect server metrics, and build dashboards that actually help.

NBy Nxeon

Prometheus collects and stores time-series metrics; Grafana turns them into beautiful, useful dashboards. Together they're the standard open-source monitoring stack for servers and applications. This guide installs both with Docker, wires up node_exporter to collect host metrics, and gets you a live dashboard. If you just want simple up/down alerts, Uptime Kuma is lighter — this stack is for metrics and trends.

What each piece does

  • node_exporter exposes CPU, memory, disk and network metrics from the host.
  • Prometheus scrapes those metrics on a schedule and stores them.
  • Grafana queries Prometheus and draws dashboards and alerts.

Prerequisites

  • A VPS with Docker installed — run Docker on a VPS.
  • Optionally a domain like grafana.example.com.

The Compose stack

mkdir -p ~/monitoring && cd ~/monitoring
services:
  prometheus:
    image: prom/prometheus:latest
    restart: unless-stopped
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prom_data:/prometheus
    ports:
      - "9090:9090"

  node_exporter:
    image: prom/node-exporter:latest
    restart: unless-stopped
    pid: host
    volumes:
      - /:/host:ro,rslave
    command:
      - '--path.rootfs=/host'

  grafana:
    image: grafana/grafana:latest
    restart: unless-stopped
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=change-me
    volumes:
      - grafana_data:/var/lib/grafana
    ports:
      - "3000:3000"

volumes:
  prom_data:
  grafana_data:

Now the Prometheus scrape config:

# prometheus.yml
global:
  scrape_interval: 15s
scrape_configs:
  - job_name: 'node'
    static_configs:
      - targets: ['node_exporter:9100']

Start everything:

docker compose up -d

Connect Grafana to Prometheus

Open http://your-server-ip:3000 and log in as admin with the password you set. Add a data source: Connections → Data sources → Prometheus, and set the URL to http://prometheus:9090. Save and test.

Deploying a new server with the Nxeon one-click deploy wizard
Deploying a new server with the Nxeon one-click deploy wizard

Import a ready-made dashboard

You don't have to build panels by hand. Grafana has a huge library of community dashboards. For node_exporter, import the well-known Node Exporter Full dashboard (ID 1860): Dashboards → New → Import, enter the ID, and pick your Prometheus source. Within seconds you have CPU, RAM, disk and network graphs for your server.

Secure it

Put Grafana behind HTTPS and restrict the firewall — leave Prometheus (9090) unexposed:

sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Front port 3000 with Caddy on grafana.example.com for automatic TLS. For a lighter-weight look at server health without a full stack, see how to monitor server resources on Linux.

Add alerts

In Grafana, create alert rules on any panel — for example, "CPU above 90% for 5 minutes" — and route them to Slack, email or a webhook. Now the stack doesn't just visualise problems, it tells you about them.

Monitor your Docker containers too

Host metrics from node_exporter are only half the picture — you'll also want per-container CPU, memory and network stats. Add cAdvisor to the stack:

  cadvisor:
    image: gcr.io/cadvisor/cadvisor:latest
    restart: unless-stopped
    volumes:
      - /:/rootfs:ro
      - /var/run:/var/run:ro
      - /sys:/sys:ro
      - /var/lib/docker/:/var/lib/docker:ro

Add a scrape job for cadvisor:8080 in prometheus.yml, reload Prometheus, and import a container dashboard in Grafana. Now you can see exactly which container is eating RAM — invaluable when you run several self-hosted apps on one box.

Retention and alerting that reaches you

Dashboards only help if someone's looking, so configure a contact point (Slack, email, Telegram or a webhook) and attach alert rules to your key panels: disk above 85%, memory saturation, a container restarting repeatedly. Set sensible evaluation intervals so you're warned early but not spammed by transient spikes. Retention is worth a thought too — Prometheus keeps metrics for 15 days by default; raise it with the --storage.tsdb.retention.time flag if you want longer history for capacity planning.

Monitoring your applications, not just the host

Server metrics tell you the box is healthy; application metrics tell you your *service* is healthy. Prometheus scrapes any endpoint that exposes metrics in its format, and most modern tools can:

  • Databases — exporters exist for PostgreSQL, MySQL, Redis and more, surfacing query rates, connections and slow queries.
  • Web servers and reverse proxies — Nginx and Caddy can expose request counts, status codes and latency.
  • Your own apps — client libraries for most languages let you emit custom metrics (requests handled, jobs queued, errors) in a few lines.

Add each as a new job_name with its target in prometheus.yml, reload, and build a Grafana panel from the new data. This is where the stack pays off: instead of guessing why something's slow, you graph request latency next to CPU and database load on one dashboard and see the cause at a glance. For a lightweight up/down view alongside these deep metrics, run Uptime Kuma too.

FAQ

Prometheus + Grafana or Uptime Kuma?

Use Uptime Kuma for simple "is it up?" checks and status pages. Use Prometheus + Grafana when you need metrics, trends and detailed dashboards. Many people run both.

Can I monitor multiple servers?

Yes. Install node_exporter on each server and add them as targets in prometheus.yml. One Grafana can visualise your whole fleet.

How much disk does Prometheus use?

It depends on retention and scrape interval, but metric storage is compact. Set a retention period that matches your needs and it stays modest for a handful of servers.

Is Grafana free?

Yes, the open-source edition is free and covers dashboards, data sources and alerting. Grafana also offers paid cloud and enterprise tiers you don't need for self-hosting.

Stand up your monitoring on a solid NVMe VPS with full root access, or explore Docker hosting built for stacks like this.

#grafana#prometheus#monitoring#docker#self-hosting#seobatch

Deploy your first server in under a minute

Creating an account is free and takes no card details. You pay when you deploy — choose a billing term and pay from your wallet or by card at checkout.