segunda-feira, 3 de outubro de 2022

Monitoring Pi-hole with Prometheus

0 comentários

 Monitoring Pi-hole with Prometheus (observability.blog)


eko/pihole-exporter
A Prometheus exporter for PI-Hole’s Raspberry PI ad blocker - eko/pihole-exporter

pihole-exporter is a Go application that exports Pi-hole metrics.

The first step is downloading the correct release. In my case I run Pi-hole on a Debian VM so I downloaded the amd64 release. If you run Pi-hole on a Raspberry Pi you will need the arm release.
https://github.com/eko/pihole-exporter/releases

# amd64 ver. 0.0.8
wget https://github.com/eko/pihole-exporter/releases/download/0.0.8/pihole_exporter-linux-amd64

# arm ver. 0.0.8
wget https://github.com/eko/pihole-exporter/releases/download/0.0.8/pihole_exporter-linux-arm

Once you have the the executable downloaded lets create a space for it

mkdir /opt/pihole_exporter

Create a system user to run the exporter

useradd -r pihole_exporter

Move the executable to the folder we created

mv pihole_exporter-linux-amd64 /opt/pihole_exporter

Make sure to set the correct permissions

chgrp pihole_exporter /opt/pihole_exporter
chgrp pihole_exporter /opt/pihole_exporter/pihole_exporter-linux-amd64
chmod +x /opt/pihole_exporter/pihole_exporter-linux-amd64
# NOTE: if you downloaded the arm release make sure you change the file name

Create a service file

nano /lib/systemd/system/pihole_exporter.service
systemctl daemon-reload
service pihole_exporter start
systemctl enable pihole_exporter
[Unit]
Description=pihole_exporter

[Service]
ExecStart=/opt/pihole_exporter/pihole_exporter-linux-amd64
WorkingDirectory=/opt/pihole_exporter
Restart=always
User=pihole_exporter

[Install]
WantedBy=multi-user.target
Service File

The exporter should now be running on port 9617

curl 127.0.0.1:9617

All thats left is to setup the Prometheus job

- job_name: pihole
  static_configs:
  - targets:
    - 10.0.4.9:9617

The Github repo also provides a Grafana Dashboard.
https://github.com/eko/pihole-exporter/blob/master/grafana/dashboard.json

Leave a Reply