Skip to main content

Export pihole metrics for prometheus

Project description

pihole_exporter.py

A prometheus exporter for PiHole written in Python 3.

Grafana Dashboard See grafana_dashboard.json

License: MIT Codacy Badge Docker Automated build

Content

Available metrics

  • Queries forwarded (24h)
  • Domains being blocked
  • Ads percentage today
  • Ads blocked today
  • DNS queries today
  • Total clients
  • Unique clients
  • Queries cached
  • Unique Domains
  • Top Queries
  • Top Ads
  • Top clients
  • Forward destinations
  • Query type
  • Reply type
  • DNS queries by host

Metrics Example

Some metrics have been redacted.

pihole_exporter_version 0.1
pihole_domains_being_blocked 573713
pihole_dns_queries_today 13961
pihole_ads_blocked_today 3443
pihole_ads_percentage_today 24.661556
pihole_unique_domains 983
pihole_queries_forwarded 4346
pihole_queries_cached 3288
pihole_clients_ever_seen 9
pihole_unique_clients 5
pihole_dns_queries_all_types 13974
pihole_reply_nodata 34
pihole_reply_nxdomain 0
pihole_reply_cname 37
pihole_reply_ip 88
pihole_status 1
pihole_gravity_last_updated 1533820315
pihole_top_queries{domain="raw.githubusercontent.com"} 321
pihole_top_queries{domain="grafana.com"} 292
pihole_top_queries{domain="connect.rom.miui.com"} 165
pihole_top_queries{domain="spectrum.s3.amazonaws.com"} 145
pihole_top_queries{domain="mtalk.google.com"} 124
pihole_top_queries{domain="www.cdn.viber.com"} 112
pihole_top_queries{domain="redirector.googlevideo.com"} 112
pihole_top_queries{domain="ntp-g7g.amazon.com"} 98
pihole_top_queries{domain="www.google.com"} 72
pihole_top_ads{domain="mobile.pipe.aria.microsoft.com"} 872
pihole_top_ads{domain="www.googleadservices.com"} 169
pihole_top_ads{domain="www.google-analytics.com"} 147
pihole_top_ads{domain="s.youtube.com"} 133
pihole_top_ads{domain="data.mistat.intl.xiaomi.com"} 114
pihole_top_ads{domain="api.brs.intl.miui.com"} 89
pihole_top_ads{domain="device-metrics-us.amazon.com"} 88
pihole_top_ads{domain="adservice.google.com"} 75
pihole_top_ads{domain="aax-eu.amazon-adsystem.com"} 73
pihole_top_ads{domain="sb.scorecardresearch.com"} 71
pihole_top_sources{client="192.168.1.10"} 2833
pihole_top_sources{client="192.168.1.2"} 2799
pihole_top_sources{client="192.168.1.1"} 1045
pihole_top_sources{client="192.168.1.7"} 332
pihole_top_sources{client="192.168.1.5"} 277
pihole_forward_destinations{resolver="blocklist|blocklist"} 31.08
pihole_forward_destinations{resolver="cache|cache"} 29.68
pihole_forward_destinations{resolver="1dot1dot1dot1.cloudflare-dns.com|1.1.1.1"} 39.23
pihole_query_type{type="A (IPv4)"} 76.53
pihole_query_type{type="AAAA (IPv6)"} 23.38
pihole_query_type{type="ANY"} 0
pihole_query_type{type="SRV"} 0
pihole_query_type{type="SOA"} 0
pihole_query_type{type="PTR"} 0.09
pihole_query_type{type="TXT"} 0

Setup

pip

PyPI

pip3 install --upgrade pihole_exporter

github master branch

pip3 install --upgrade git+https://github.com/dr1s/pihole_exporter.py.git

manual

git clone https://github.com/dr1s/pihole_exporter.py.git
cd pihole_exporter.py
pip3 install -r requirements.txt
cd pihole_exporter
./pihole_exporter.py

Docker

docker-hub

docker pull dr1s/pihole_exporter
docker run --net=host -v /etc/pihole:/etc/pihole -t dr1s/pihole_exporter

manual

git clone https://github.com/dr1s/pihole_exporter.py.git
docker build -t dr1s/pihole_exporter .
docker run -d --net=host -v /etc/pihole:/etc/pihole -t dr1s/pihole_exporter

Usage

usage: pihole_exporter.py [-h] [-o PIHOLE] [-p PORT] [-i INTERFACE] [-a AUTH]

pihole_exporter

optional arguments:
-h, --help            show this help message and exit
-o PIHOLE, --pihole PIHOLE
										pihole adress
-p PORT, --port PORT  port pihole_exporter is listening on
-i INTERFACE, --interface INTERFACE
								interface pihole_exporter will listen on
-a AUTH, --auth AUTH  Pihole password hash

Usage Example

pihole_exporter --pihole pi.hole --interface 0.0.0.0 --port 9311

The previous used arguements are the default options. If nothing needs to be changed, pihole_exporter can be started without arguments.

pihole_exporter

Authentication

If pihole_exporter is installed on the same host as pihole and the auth argument is not set, pihole_exporter will try to read the password from setupVars.conf

Otherwise get the hashed password from setupVars.conf:

$ grep WEBPASSWORD /etc/pihole/setupVars.conf
WEBPASSWORD=da1a51f575cd740be233d22548ecac1dbcc96ffa297283a6a204f9213a8aca71

Use this hash as the argument for --auth

pihole_exporter --auth da1a51f575cd740be233d22548ecac1dbcc96ffa297283a6a204f9213a8aca71
docker run -d --net=host -t dr1s/pihole_exporter --pihole pi.hole --auth da1a51f575cd740be233d22548ecac1dbcc96ffa297283a6a204f9213a8aca71

Prometheus config

- job_name: 'pihole'
  static_configs:
  - targets: ['pi.hole:9311']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pihole_exporter-0.4.2.tar.gz (6.0 kB view details)

Uploaded Source

Built Distributions

pihole_exporter-0.4.2-py3.7.egg (10.6 kB view details)

Uploaded Egg

pihole_exporter-0.4.2-py2.py3-none-any.whl (6.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pihole_exporter-0.4.2.tar.gz.

File metadata

  • Download URL: pihole_exporter-0.4.2.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.7.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pihole_exporter-0.4.2.tar.gz
Algorithm Hash digest
SHA256 ccf12a656633348315159488dffb8e103b11369ae1bfcb084df1bdab452c216d
MD5 1ea52d533f579e2a9e0efdbd1b19d22f
BLAKE2b-256 a71bc02d9a453b848d0c80193fca77b2a38bac4fac70abe1607dfc6165e74c0f

See more details on using hashes here.

File details

Details for the file pihole_exporter-0.4.2-py3.7.egg.

File metadata

  • Download URL: pihole_exporter-0.4.2-py3.7.egg
  • Upload date:
  • Size: 10.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.7.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pihole_exporter-0.4.2-py3.7.egg
Algorithm Hash digest
SHA256 870b94ceca75100eeb02e7d6646d744968e37d5a9af2d9de93537912f7725de2
MD5 6b2c56292f494f535668774507e77a65
BLAKE2b-256 0966256f7d87b474a81b7097719c578959581cb7db682032dfb4efe16f566e0d

See more details on using hashes here.

File details

Details for the file pihole_exporter-0.4.2-py2.py3-none-any.whl.

File metadata

  • Download URL: pihole_exporter-0.4.2-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.7.0 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.7.0

File hashes

Hashes for pihole_exporter-0.4.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ebd51e129d2de49b28c8497c155f095bcfe4475b54ca722a5821d4ca834fb0af
MD5 65750b64b4c49955667b3168c3b80519
BLAKE2b-256 9f3c1c6706c6dc3fdf0080d9809e1e1ad2afceb05659add8cce2948904ef684e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page