Skip to Content

Self-Host Prometheus: Production-Grade Metrics & Monitoring in 15 Minutes

Self-Host Prometheus: Production-Grade Metrics & Monitoring in 15 Minutes

Published on | 12 min read

Your homelab is growing. You've got containers spinning up, databases filling with data, and services that will fail at 3 AM when nobody's watching. Grafana gives you beautiful dashboards, but dashboards need data. That's where Prometheus comes in — the industry-standard metrics collection engine that powers monitoring at every scale from Raspberry Pi clusters to Fortune 500 infrastructure.

In this guide, you'll deploy a complete Prometheus stack with Node Exporter for system metrics, ready to feed into Grafana or alert you directly when things go sideways.

Why Self-Host Prometheus?

  • Vendor independence — Your metrics stay on your hardware, not in Datadog's billing system
  • No per-metric pricing — Scrape 10,000 metrics or 10 million; the cost is the same VPS you're already paying for
  • Native container support — Prometheus speaks Docker and Kubernetes fluently
  • Alertmanager included — Route alerts to email, Slack, Discord, or PagerDuty without third-party services

Prerequisites

  • A VPS or dedicated server with 2+ CPU cores, 4GB RAM, 20GB disk
  • Docker and Docker Compose installed (see our Portainer guide if you need a refresher)
  • Basic familiarity with YAML configuration

Step 1: Create the Project Structure

```bash mkdir -p ~/prometheus/{data,config} cd ~/prometheus ```

Step 2: Configure Prometheus

Create config/prometheus.yml: ```yaml global: scrape_interval: 15s evaluation_interval: 15s external_labels: monitor: 'homelab' rule_files: - "alert_rules.yml" alerting: alertmanagers: - static_configs: - targets: ['alertmanager:9093'] scrape_configs: # Prometheus itself - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] # Node Exporter — system metrics - job_name: 'node-exporter' static_configs: - targets: ['node-exporter:9100'] labels: instance: 'homelab-main' # Docker daemon metrics (optional, requires daemon config) - job_name: 'docker' static_configs: - targets: ['host.docker.internal:9323'] # Any service with /metrics endpoint - job_name: 'services' static_configs: - targets: [] ```

Step 3: Create Alert Rules

Create config/alert_rules.yml: ```yaml groups: - name: homelab-alerts rules: - alert: HighCPUUsage expr: 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > 80 for: 5m labels: severity: warning annotations: summary: "High CPU usage on {{ $labels.instance }}" description: "CPU usage is above 80% for 5 minutes" - alert: LowDiskSpace expr: (node_filesystem_avail_bytes / node_filesystem_size_bytes) * 100 < 15 for: 10m labels: severity: critical annotations: summary: "Low disk space on {{ $labels.instance }}" description: "Disk {{ $labels.mountpoint }} has less than 15% free" - alert: ServiceDown expr: up == 0 for: 2m labels: severity: critical annotations: summary: "Service {{ $labels.job }} is down" description: "{{ $labels.instance }} has been down for 2+ minutes" ```

Step 4: Docker Compose Stack

Create docker-compose.yml: ```yaml version: '3.8' services: prometheus: image: prom/prometheus:latest container_name: prometheus restart: unless-stopped command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--storage.tsdb.retention.time=30d' - '--web.console.libraries=/etc/prometheus/console_libraries' - '--web.console.templates=/etc/prometheus/consoles' - '--web.enable-lifecycle' ports: - "9090:9090" volumes: - ./config:/etc/prometheus - ./data:/prometheus networks: - monitoring node-exporter: image: prom/node-exporter:latest container_name: node-exporter restart: unless-stopped command: - '--path.rootfs=/host' pid: host ports: - "9100:9100" volumes: - '/:/host:ro,rslave' networks: - monitoring alertmanager: image: prom/alertmanager:latest container_name: alertmanager restart: unless-stopped ports: - "9093:9093" volumes: - ./alertmanager:/config command: --config.file=/config/alertmanager.yml networks: - monitoring networks: monitoring: driver: bridge ```

Step 5: Launch the Stack

```bash docker compose up -d # Verify all containers are running docker compose ps # Check Prometheus is healthy curl http://localhost:9090/-/healthy ```

Step 6: Verify Metrics Collection

1. Open http://your-server-ip:9090 in your browser 2. Navigate to Status → Targets — you should see all scrape targets as UP 3. Go to the Graph tab and test a query: ```promql # CPU usage percentage 100 - (avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) # Memory usage (node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes) / node_memory_MemTotal_bytes * 100 # Disk I/O rate(node_disk_read_bytes_total[5m]) ```

Step 7: Connect to Grafana (Optional but Recommended)

If you followed our Grafana guide, add Prometheus as a data source: 1. Grafana → Configuration → Data Sources → Add data source 2. Select Prometheus 3. URL: http://prometheus:9090 (if on same Docker network) or http://your-server-ip:9090 4. Save & Test — you should see a green confirmation Import dashboard ID 1860 (Node Exporter Full) for instant, detailed system metrics.

Production Hardening Tips

ConcernSolution
Data retentionAdjust --storage.tsdb.retention.time (default 30d). For 90 days: 90d
Remote storageUse Thanos or Cortex for long-term storage across multiple Prometheus instances
SecurityPut behind Traefik with basic auth or OAuth (see our Traefik guide)
High availabilityRun two identical Prometheus instances with identical configs; use a load balancer
Alert fatigueTune for: durations and use Alertmanager inhibition rules to suppress cascades

Next Steps

  • Add service monitors — Most modern apps expose /metrics; just add a scrape config
  • Deploy Grafana — Visualize everything with pre-built dashboards from grafana.com
  • Set up Alertmanager — Route critical alerts to Discord, Slack, or email
  • Explore exporters — postgres_exporter, redis_exporter, blackbox_exporter for deep service monitoring

Prometheus is the backbone of observable infrastructure. Once it's running, every other service you deploy becomes measurable, alertable, and debuggable. Your future self — the one not woken up at 3 AM by a silent disk failure — will thank you.


Questions or want a specific exporter covered? Drop a comment below or reach out on our Discord.

Self-Host Grafana: Beautiful Dashboards for Your Homelab in 15 Minutes