Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
P

pihole-exporter

> DevOps
Open source

A Prometheus exporter for PI-Hole's Raspberry PI ad blocker

1.2K stars0 likes2 views
WebsiteGitHub

About

A Prometheus exporter for PI-Hole's Raspberry PI ad blocker

Pi-hole Prometheus Exporter

Build/Push (master) This is a Prometheus exporter for Pi-hole's Raspberry PI ad blocker.

Available Grafana Dasboards:

  • Prometheus: Grafana Labs / JSON/Github --> Preview
  • InfluxDB 2 (Flux): Grafana Labs / JSON/Github --> Preview

Prerequisites

  • Go

Installation

Download binary

You can download the latest version of the binary built for your architecture here:

  • Architecture i386 [ Linux / Windows ]
  • Architecture amd64 [ Darwin / Linux / Windows ]
  • Architecture arm [ Darwin / Linux ]

Using Docker

The exporter is also available as a Docker image. You can run it using the following example and pass configuration environment variables:

bash
$ docker run \
  -e 'PIHOLE_HOSTNAME=192.168.1.2' \
  -e 'PIHOLE_PASSWORD=mypassword' \
  -e 'PORT=9617' \
  -p 9617:9617 \
  ekofr/pihole-exporter:latest

Or use PiHole's WEBPASSWORD as an API token instead of the password

bash
$ 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:latest

If 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:

bash
$ 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:latest

If 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=true

A 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:

bash
$ 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:latest

If port, protocol and API token/password is the same for all instances, you can specify them only once:

bash
$ 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:latest

From sources

Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way:

bash
$ go install github.com/eko/pihole-exporter@latest
# or
$ git clone https://github.com/eko/pihole-exporter.git

Install the needed vendors:

$ go mod vendor

Then, build the binary (here, an example to run on Raspberry PI ARM architecture):

bash
$ GOOS=linux GOARCH=arm GOARM=7 go build -o pihole_exporter .

Usage

In order to run the exporter, type the following command (arguments are optional):

Using a password

bash
$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_password azerty

Or use PiHole's WEBPASSWORD as an API token instead of the password

bash
$ 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_TOKEN

Debug logging

You 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:

yaml
scrape_configs:
    - job_name: "pihole"
      static_configs:
          - targets: ["localhost:9617"]

Available CLI options

…

Available Prometheus metrics

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

Pihole-Exporter Helm Chart

Link

This is a simple Helm Chart to deploy the exporter in a kubernetes cluster.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Godockergrafanagrafana-dashboardhacktoberfest

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理