A Raspberry Pi 4 (4 GB) costs $55. For that price you get a always-on Linux box that can block ads network-wide, collect metrics from every device on your network, and serve a Grafana dashboard — all simultaneously.
What we are building
- Pi-hole — DNS-level ad and tracker blocker for the entire network
- Prometheus — time-series metrics collector
- Grafana — dashboard to visualise everything
- pihole-exporter — bridge between Pi-hole stats and Prometheus
Install Pi-hole
curl -sSL https://install.pi-hole.net | bash
Set a static IP on the Pi first. Then point your router’s DHCP to hand out the Pi’s IP as the DNS server for all clients.
# /etc/dhcpcd.conf
interface eth0
static ip_address=10.0.20.10/24
static routers=10.0.20.1
static domain_name_servers=127.0.0.1
Install Prometheus
sudo apt install prometheus
Default config scrapes itself every 15s. We will add pihole-exporter as a target.
Install pihole-exporter
wget https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-arm
chmod +x pihole_exporter-linux-arm
./pihole_exporter-linux-arm -pihole_hostname 127.0.0.1
Add to Prometheus scrape config:
scrape_configs:
- job_name: pihole
static_configs:
- targets: ['localhost:9617']
Install Grafana
sudo apt install grafana
sudo systemctl enable --now grafana-server
Import dashboard ID 10176 (Pi-hole Exporter) from grafana.com — it gives you blocked queries %, top blocked domains, query rate, and client breakdown out of the box.
Metrics worth watching
- Blocked % — healthy range is 15–30%. Much lower means blocklists are stale. Much higher might mean false positives.
- Query rate by client — spot anomalous devices making thousands of queries per minute (IoT malware signature).
- Top permitted domains — tells you what your devices actually phone home to.
Performance on Pi 4
After 30 days of continuous operation: CPU never exceeded 12%, RAM usage settled at ~380 MB. The SD card is the bottleneck — use a good A2-rated card or boot from USB SSD.