Tutorials

Set Up a Complete Monitoring Stack with Grafana and Prometheus

Learn how to deploy Grafana, Prometheus, and Node Exporter using Docker Compose for comprehensive infrastructure monitoring with beautiful dashboards.

February 5, 202610 min read
Set Up a Complete Monitoring Stack with Grafana and Prometheus

Monitoring is essential for any self-hosted setup. In this tutorial, we'll build a complete monitoring stack using Grafana and Prometheus that gives you real-time visibility into your infrastructure.

Architecture Overview

  • Prometheus - Time-series database that scrapes metrics
  • Node Exporter - Exposes host-level metrics (CPU, memory, disk)
  • Grafana - Visualization and dashboarding
  • Alertmanager - Alert routing and notifications
  • Docker Compose Setup

    services:

    prometheus:

    image: prom/prometheus:v2.51.0

    volumes:

  • ./prometheus.yml:/etc/prometheus/prometheus.yml
  • prometheus_data:/prometheus
  • ports:

  • "9090:9090"
  • command:

  • '--config.file=/etc/prometheus/prometheus.yml'
  • '--storage.tsdb.retention.time=30d'
  • grafana:

    image: grafana/grafana:10.4.0

    ports:

  • "3000:3000"
  • volumes:

  • grafana_data:/var/lib/grafana
  • environment:

  • GF_SECURITY_ADMIN_PASSWORD=changeme
  • depends_on:

  • prometheus
  • node-exporter:

    image: prom/node-exporter:v1.7.0

    ports:

  • "9100:9100"
  • volumes:

  • /proc:/host/proc:ro
  • /sys:/host/sys:ro
  • command:

  • '--path.procfs=/host/proc'
  • '--path.sysfs=/host/sys'
  • volumes:

    prometheus_data:

    grafana_data:

    Prometheus Configuration

    Create prometheus.yml:

    global:

    scrape_interval: 15s

    scrape_configs:

  • job_name: 'prometheus'
  • static_configs:

  • targets: ['localhost:9090']
  • job_name: 'node'
  • static_configs:

  • targets: ['node-exporter:9100']
  • Setting Up Grafana Dashboards

  • Open Grafana at http://localhost:3000
  • Add Prometheus as a data source (http://prometheus:9090)
  • Import dashboard ID 1860 for Node Exporter Full
  • Customize panels to show the metrics you care about
  • Adding Alerts

    Configure Alertmanager for Slack, email, or webhook notifications when metrics cross thresholds. This ensures you're notified before issues become critical.

    Conclusion

    This monitoring stack gives you enterprise-grade observability for your homelab. Extend it by adding cAdvisor for container metrics, Blackbox Exporter for endpoint monitoring, and Loki for log aggregation.