A Prometheus exporter for PI-Hole's Raspberry PI ad blocker
A Prometheus exporter for PI-Hole's Raspberry PI ad blocker
This is a Prometheus exporter for Pi-hole's Raspberry PI ad blocker.
Available Grafana Dasboards:
You can download the latest version of the binary built for your architecture here:
The exporter is also available as a Docker image. You can run it using the following example and pass configuration environment variables:
$ docker run \
-e 'PIHOLE_HOSTNAME=192.168.1.2' \
-e 'PIHOLE_PASSWORD=mypassword' \
-e 'PORT=9617' \
-p 9617:9617 \
ekofr/pihole-exporter:latestOr use PiHole's WEBPASSWORD as an API token instead of the password
$ API_TOKEN=$(awk -F= -v key="WEBPASSWORD" '$1==key {print $2}' /etc/pihole/setupVars.conf)
$ docker run \
-e 'PIHOLE_HOSTNAME=192.168.1.2' \
-e "PIHOLE_PASSWORD=$API_TOKEN" \
-e 'PORT=9617' \
-p 9617:9617 \
ekofr/pihole-exporter:latestIf you are running pi-hole behind https, you must both set the PIHOLE_PROTOCOL environment variable
as well as include your ssl certificates to the docker image as it does not have any baked in:
$ docker run \
-e 'PIHOLE_PROTOCOL=https' \
-e 'PIHOLE_HOSTNAME=192.168.1.2' \
-e 'PIHOLE_PASSWORD=mypassword' \
-e 'PORT=9617' \
-v '/etc/ssl/certs:/etc/ssl/certs:ro' \
-p 9617:9617 \
ekofr/pihole-exporter:latestIf you want to skip SSL certificate verification, pass in the following to either your Docker Compose file (-e) or the file holding environment variables (e.g. .env):
SKIP_TLS_VERIFICATION=trueA single instance of pihole-exporter can monitor multiple pi-holes instances. To do so, you can specify a list of hostnames, protocols, passwords/API tokens and ports by separating them with commas in their respective environment variable:
$ docker run \
-e 'PIHOLE_PROTOCOL=http,http,http" \
-e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
-e "PIHOLE_PASSWORD=$API_TOKEN1,$API_TOKEN2,$API_TOKEN3" \
-e "PIHOLE_PORT=8080,8081,8080" \
-e 'PORT=9617' \
-p 9617:9617 \
ekofr/pihole-exporter:latestIf port, protocol and API token/password is the same for all instances, you can specify them only once:
$ docker run \
-e 'PIHOLE_PROTOCOL=http" \
-e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
-e "PIHOLE_PASSWORD=$API_TOKEN" \
-e "PIHOLE_PORT=8080" \
-e 'PORT=9617' \
-p 9617:9617 \
ekofr/pihole-exporter:latestOptionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way:
$ go install github.com/eko/pihole-exporter@latest
# or
$ git clone https://github.com/eko/pihole-exporter.gitInstall the needed vendors:
$ go mod vendorThen, build the binary (here, an example to run on Raspberry PI ARM architecture):
$ GOOS=linux GOARCH=arm GOARM=7 go build -o pihole_exporter .In order to run the exporter, type the following command (arguments are optional):
Using a password
$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_password azertyOr use PiHole's WEBPASSWORD as an API token instead of the password
$ API_TOKEN=$(awk -F= -v key="WEBPASSWORD" '$1==key {print $2}' /etc/pihole/setupVars.conf)
$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_password $API_TOKENYou can enable verbose output either by environment variable or CLI flag:
Both options set logrus to debug level (shown below); otherwise the exporter logs at info.
…Once the exporter is running, you also have to update your prometheus.yml configuration to let it scrape the exporter:
scrape_configs:
- job_name: "pihole"
static_configs:
- targets: ["localhost:9617"]…| Metric name | Description |
|---|---|
| pihole_domains_being_blocked | This represent the number of domains being blocked |
| pihole_dns_queries_today | This represent the number of DNS queries made over the current day |
| pihole_ads_blocked_today | This represent the number of ads blocked over the current day |
| pihole_ads_percentage_today | This represent the percentage of ads blocked over the current day |
| pihole_unique_domains | This represent the number of unique domains seen |
| pihole_queries_forwarded | This represent the number of queries forwarded |
| pihole_queries_cached | This represent the number of queries cached |
| pihole_clients_ever_seen | This represent the number of clients ever seen |
| pihole_unique_clients | This represent the number of unique clients seen |
| pihole_dns_queries_all_types | This represent the number of DNS queries made for all types |
| pihole_reply | This represent the number of replies made for all types |
| pihole_top_queries | This represent the number of top queries made by Pi-hole by domain |
| pihole_top_ads | This represent the number of top ads made by Pi-hole by domain |
| pihole_top_sources | This represent the number of top sources requests made by Pi-hole by source host |
| pihole_forward_destinations | This represent the number of forward destinations requests made by Pi-hole by destination |
| pihole_querytypes | This represent the number of queries made by Pi-hole by type |
| pihole_status | This represent if Pi-hole is enabled |
| queries_last_10min | This represent the number of queries in the last full slot of 10 minutes |
| ads_last_10min | This represent the number of ads in the last full slot of 10 minutes |
This is a simple Helm Chart to deploy the exporter in a kubernetes cluster.
No open issues yet, or sync has not completed.