← Back to Projects

Monitoring Stack (Prometheus + Grafana)

Full-stack observability for the homelab — metrics from all VMs and network devices, dashboards in Grafana, alerts to Telegram.

Grafana Prometheus SNMP Monitoring Alerting
1 November 2024

What

A monitoring stack modeled after what we run at Datanet, but built from scratch so I understand every piece. Prometheus scrapes metrics from exporters on each VM plus SNMP data from network devices. Grafana visualizes everything. Alertmanager fires alerts to a Telegram bot.

Components:

ToolRole
PrometheusMetrics collection & storage
Node ExporterPer-VM CPU, RAM, disk, network
SNMP ExporterNetwork device metrics (pfSense, switch)
GrafanaDashboards
AlertmanagerAlert routing
Telegram BotAlert delivery

Why

At work I use commercial SNMP polling tools (LibreNMS, PRTG). Building a Prometheus stack from scratch forces me to understand the underlying mechanics — scrape intervals, cardinality, PromQL. It also means I can monitor my own infrastructure the way we monitor the ISP backbone.

How

All components run as Docker Compose services on a dedicated Debian VM (2 vCPU, 4 GB RAM, VLAN 20).

# docker-compose.yml (excerpt)
services:
  prometheus:
    image: prom/prometheus:v2.50.1
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus_data:/prometheus
    ports:
      - "9090:9090"

  grafana:
    image: grafana/grafana:10.3.1
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_PASS}
    volumes:
      - grafana_data:/var/lib/grafana
    ports:
      - "3000:3000"

  alertmanager:
    image: prom/alertmanager:v0.26.0
    volumes:
      - ./alertmanager.yml:/etc/alertmanager/alertmanager.yml

SNMP Exporter for pfSense

pfSense exposes standard MIBs. The SNMP exporter uses the if_mib module to scrape interface counters:

# prometheus.yml scrape config
- job_name: 'snmp_pfsense'
  static_configs:
    - targets: ['10.10.99.1']
  metrics_path: /snmp
  params:
    module: [if_mib]
  relabel_configs:
    - source_labels: [__address__]
      target_label: __param_target
    - target_label: __address__
      replacement: snmp-exporter:9116

Key Alerts

Challenges

Tech Used