Giter VIP home page Giter VIP logo

pihole-exporter's Introduction

Pi-hole Prometheus Exporter

Build/Push (master) GoDoc GoReportCard

This is a Prometheus exporter for Pi-hole's Raspberry PI ad blocker.

Grafana dashboard

Available Grafana Dasboards:

Prerequisites

Installation

Download binary

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

Using Docker

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

Or 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_API_TOKEN=$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:

$ 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

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:

$ 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_API_TOKEN=$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:

$ docker run \
  -e 'PIHOLE_PROTOCOL=http" \
  -e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
  -e "PIHOLE_API_TOKEN=$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:

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

Install the needed vendors:

$ GO111MODULE=on go mod vendor

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

$ 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

$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_password azerty

Or 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_api_token $API_TOKEN
2019/05/09 20:19:52 ------------------------------------
2019/05/09 20:19:52 -  Pi-hole exporter configuration  -
2019/05/09 20:19:52 ------------------------------------
2019/05/09 20:19:52 PIHoleHostname : 192.168.1.10
2019/05/09 20:19:52 PIHolePassword : azerty
2019/05/09 20:19:52 Port : 9617
2019/05/09 20:19:52 Timeout : 5s
2019/05/09 20:19:52 ------------------------------------
2019/05/09 20:19:52 New Prometheus metric registered: domains_blocked
2019/05/09 20:19:52 New Prometheus metric registered: dns_queries_today
2019/05/09 20:19:52 New Prometheus metric registered: ads_blocked_today
2019/05/09 20:19:52 New Prometheus metric registered: ads_percentag_today
2019/05/09 20:19:52 New Prometheus metric registered: unique_domains
2019/05/09 20:19:52 New Prometheus metric registered: queries_forwarded
2019/05/09 20:19:52 New Prometheus metric registered: queries_cached
2019/05/09 20:19:52 New Prometheus metric registered: clients_ever_seen
2019/05/09 20:19:52 New Prometheus metric registered: unique_clients
2019/05/09 20:19:52 New Prometheus metric registered: dns_queries_all_types
2019/05/09 20:19:52 New Prometheus metric registered: reply
2019/05/09 20:19:52 New Prometheus metric registered: top_queries
2019/05/09 20:19:52 New Prometheus metric registered: top_ads
2019/05/09 20:19:52 New Prometheus metric registered: top_sources
2019/05/09 20:19:52 New Prometheus metric registered: forward_destinations
2019/05/09 20:19:52 New Prometheus metric registered: querytypes
2019/05/09 20:19:52 New Prometheus metric registered: status
2019/05/09 20:19:52 Starting HTTP server
2019/05/09 20:19:54 New tick of statistics: 648 ads blocked / 66796 total DNS querie
...

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']

Available CLI options

# Hostname of the host(s) where Pi-hole is installed
  -pihole_hostname string (optional) (default "127.0.0.1")

# Password defined on the Pi-hole interface
  -pihole_password string (optional)

# Timeout to connect and retrieve data from a Pi-hole instance
  -timeout duration (optional) (default 5s)

# WEBPASSWORD / api token defined on the Pi-hole interface at `/etc/pihole/setupVars.conf`
  -pihole_api_token string (optional)

# Address to be used for the exporter
  -bind_addr string (optional) (default "0.0.0.0")

# Port to be used for the exporter
  -port string (optional) (default "9617")

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

Pihole-Exporter Helm Chart

Link

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

pihole-exporter's People

Contributors

adam-moss avatar andrewchumchal avatar cfultz avatar csmarchbanks avatar darmiel avatar darnfish avatar dependabot-preview[bot] avatar dependabot[bot] avatar eko avatar galorhallen avatar htr avatar jmherbst avatar kbreit avatar onovy avatar pbirkle avatar pecastro avatar rafi0101 avatar santigz avatar shaned24 avatar sim22 avatar spikegrobstein avatar sshah7433 avatar sylr avatar tsunam avatar vremenar avatar wblew avatar webash avatar xonvanetta avatar zhengyi13 avatar zozman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pihole-exporter's Issues

connect: connection refused

I set up my prometheus and pihole-exporter with docker on my synology. Unfortunately no data will be sent to prometheus. And it seems, /metrics on port 9617 is also not available though data from my pihole has been received.

  • targets tells me, my localhost:9617/metrics is down, no data has been written. Get "http://localhost:9617/metrics": dial tcp 127.0.0.1:9617: connect: connection refused
  • http://10.0.0.13/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&jsonForceObjectshows data also the logs from pihole-exporter so the exporter itself works, but without writing the data.

prometheus.yml:

scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']
  - job_name: 'pihole'
    static_configs:
    - targets: ['localhost:9617']

Default prometheus data has been written from that scrape but not from pihole scrape which is running on the same machine.

Here are my settings:

Environment:
PIHOLE_HOSTNAME=10.0.0.13
PIHOLE_API_TOKEN=xxx 
INTERVAL=30s
PORT=9617

Ports:
9617:9617 

Metrics violating prometheus best practices

Metrics exposed by this exporter doesn't conform to Prometheus Best Practices in metric naming and to its data model. This can be confusing (for example it is unclear why pihole_forward_destinations is a floating point number when querying from prometheus console).
Additionally sometimes metrics are named in the plural and sometimes in the singular form (pihole_reply vs pihole_forward_destinations).

Steps for Reproduction

  1. Start exporter
  2. Go to exporter /metrics endpoint
  3. Go to prometheus and query metrics

Expected behavior:

  • Metrics are easily identified, have meaningful descriptions and user can see metric unit where appropriate
  • Metrics are following Prometheus Best Practices

Actual behavior:

For example following metrics are not easily understandable and can be misleading:

  • pihole_reply - what is the unit? What is the type (counter? gauge? this is important if you want to do prometheus operations like rate)?
  • pihole_querytypes - description says This represent the number of unique domains seen, so why not convert it to counter and call pihole_unique_domains_seen_total?
  • pihole_forward_destinations this is not storing "destinations" as metric name would suggest, neither number of forward destinations requests like description would suggest. Instead, its purpose is revealed only at the last step in grafana dashboard as a percent of requests towards a destination. Apart from a slight cardinality issue, which is cleverly solved by DNS itself, the name of metric and its description don't allow for easy understanding. I would propose to change it to something like pihole_forward_destinations_requests_percent
  • clients_ever_seen this should be a counter as this metric cannot go down

I don't want to go over all metrics, but above list is not a complete reference. Additionally, some metrics have unbound cardinality issues (like clients_ever_seen), but I get that it might be nice to have them exported as is).

Platforms:

All

Versions:

latest (0.0.6)

Additional info

Just a question: I glanced over code and why every metric is a gauge? I think things like dns_queries_today or unique_domains easily could be counters and thus allow for more operations on prometheus side (prometheus code internally prefers counters over gauges).

Permission Denied error running AMD64 binary

When running the AMD64 binary, bash errors out with a Permission Denied error, even when using root privileges.

Steps for Reproduction

  1. Download binary using wget https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-amd64
  2. Launch binary with ./pihole_exporter-linux-amd64 with root
  3. Observe error

Expected behavior: Get an error from application.

Actual behavior: Get an error from bash saying that permission is denied, even when using root.

Platforms:

Debian 10, Pi-hole 5.1.2

Versions:

Pi-hole 5.1.2, Binary version 0.0.10, downloaded as of 10/29/2020.

Unable to unmarshal PI-Hole statistics to statistics struct model invalid character 'F' looking for beginning of value

First: Thank you for building this tool! I am grateful that it exists and is free!


Steps for Reproduction

I am running piHole behind a proxy. This allows me to redirect http requests to HTTPS.
I am getting the error seen above when I try to run the exporter.

Here's a fuller output:

# systemctl start phole-metrics; journalctl -xfe -u pihole-metrics
    <SNIP> 
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 ------------------------------------
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 -  PI-Hole exporter configuration  -
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 ------------------------------------
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 PIHoleHostname : 127.0.0.1
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 PIHolePassword : my-pihole-password
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 Port : 9617
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 Interval : 10s
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 ------------------------------------
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: domains_blocked
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: dns_queries_today
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: ads_blocked_today
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: ads_percentag_today
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: unique_domains
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: queries_forwarded
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: queries_cached
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: clients_ever_seen
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: unique_clients
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: dns_queries_all_types
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: reply
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: top_queries
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: top_ads
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: top_sources
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: forward_destinations
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: querytypes
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 New Prometheus metric registered: status
Feb 08 18:42:01 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:01 Starting HTTP server
Feb 08 18:42:11 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:11 Unable to unmarshal PI-Hole statistics to statistics struct model invalid character 'F' looking for beginning of value
Feb 08 18:42:11 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:11 New tick of statistics: 0 ads blocked / 0 total DNS queries
Feb 08 18:42:21 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:21 Unable to unmarshal PI-Hole statistics to statistics struct model invalid character 'F' looking for beginning of value
Feb 08 18:42:21 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:21 New tick of statistics: 0 ads blocked / 0 total DNS queries
Feb 08 18:42:31 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:31 Unable to unmarshal PI-Hole statistics to statistics struct model invalid character 'F' looking for beginning of value
Feb 08 18:42:31 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:31 New tick of statistics: 0 ads blocked / 0 total DNS queries
Feb 08 18:42:41 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:41 Unable to unmarshal PI-Hole statistics to statistics struct model invalid character 'F' looking for beginning of value
Feb 08 18:42:41 myHost pihole-metrics-exporter[8897]: 2020/02/08 18:42:41 New tick of statistics: 0 ads blocked / 0 total DNS queries
^C

I am not a golang person, but i was able to poke about and found the URL you hit for stats scraping. I don't know how to force a more verbose log from the err = json.Unmarshal(body, &stats) call.

In any event here's what I was able to pull from my piHole through the proxy using curl:

  1. Log in; submit the PW and store the cookie in the cookie-jar so i can re-use the cookies when i request the stats. I have told cURL to ignore TLS certificate issues (--insecure) and follow any redirects (-L):
root@myHost:/# curl 'https://my.host.ip.v4/admin/index.php?login' --cookie-jar ./cookies --insecure -L -H 'Origin: https://my.host.ip.v4' -H 'Referer: https://my.host.ip.v4/admin/index.php?login' -H 'Cookie: PHPSESSID=m2ei7n7d49h7t04is85gp1325j' -H 'TE: Trailers' --data 'pw=my-pihole-password'
<!DOCTYPE html>
<!-- Pi-hole: A black hole for Internet advertisements
*  (c) 2017 Pi-hole, LLC (https://pi-hole.net)
*  Network-wide ad blocking via your own hardware.
*
*  This file is copyright under the latest version of the EUPL.
*  Please see LICENSE file for your rights under this license. -->
<html>
<head>
   <SNIP>
</body>
</html>

Now, request the stats:

root@myHost:/# curl 'http://my.host.ip.v4/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&jsonForceObject' --cookie-jar ./cookies --insecure -L

{"domains_being_blocked":1,"dns_queries_today":1817,"ads_blocked_today":0,"ads_percentage_today":0,"unique_domains":17,"queries_forwarded":240,"queries_cached":1577,"clients_ever_seen":1,"unique_clients":1,"dns_queries_all_types":1817,"reply_NODATA":34,"reply_NXDOMAIN":1,"reply_CNAME":112,"reply_IP":1577,"privacy_level":0,"status":"enabled","gravity_last_updated":{"file_exists":true,"absolute":1581212031,"relative":{"days":"0","hours":"01","minutes":"15"}}}

That looks like valid JSON to me, so i'm going to assume that something else is in body when it's passed onto json.Unpashal.

Again: not a golang person... but this would look like either ReadAll is objecting to TLS certificate error or is not following redirects. Can't be certain as body is never dumped to console :/.

Versions:

Which versions are you running?

side note strongly consider adding a git hash into the built binary. See here for a golang related technique.

This way, the startup preamble text that gets logged would clue you into the version :).

Anyways, i am using version 0.0.8 the linux/64 version:
I am not using docker. I am using systemd

root@myHost:/# shasum $(which pihole-metrics-exporter)
efe4169bc237861378aac6c7a497cfbdd41bc3c7  /usr/bin/pihole-metrics-exporter
root@myHost:/# pihole-metrics-exporter --version
flag provided but not defined: -version
Usage of pihole-metrics-exporter:
  -interval duration
    	 (default 10s)
  -pihole_hostname string
    	 (default "127.0.0.1")
  -pihole_password string

  -port string
    	 (default "9617")

Let me know if there's anything else i can do to help.

Support for multiply PI Hole Servers central Prometheus

Hello,

any idea for Support for multiply PI Hole Servers? One central Prometheus Servers? And exporter are running on each PI Hole? Or one central Prometheus Server and one or two exporters on the Prometheus?

Did I need two exporters or can I use one exporter for two PI Holes?

Docker environment var documentation

Would it be possible to add the possible password environment vars to the documentation?
-e PIHOLE_PASSWORD=xxxxxx
Guess It would help many people to save time.

Some metrics missing

Hi there,
The following metrics are missing for me
Top queries by domain
Top ads by domain
Top queries
Top ads domains

Pihole version is 5.0 which might be a problem?

When I start the process I get this

New Prometheus metric registered: domains_blocked
New Prometheus metric registered: dns_queries_today`
New Prometheus metric registered: ads_blocked_today
New Prometheus metric registered: ads_percentag_today
New Prometheus metric registered: unique_domains
New Prometheus metric registered: queries_forwarded
New Prometheus metric registered: queries_cached
New Prometheus metric registered: clients_ever_seen
New Prometheus metric registered: unique_clients
New Prometheus metric registered: dns_queries_all_types
New Prometheus metric registered: reply
New Prometheus metric registered: top_queries
New Prometheus metric registered: top_ads
New Prometheus metric registered: top_sources
New Prometheus metric registered: forward_destinations
New Prometheus metric registered: querytypes
New Prometheus metric registered: status

Many thanks

Jason

Dependabot can't parse your go.mod

Dependabot couldn't parse the go.mod found at /go.mod.

The error Dependabot encountered was:

go: github.com/heetch/[email protected] requires
	gopkg.in/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /opt/go/gopath/pkg/mod/cache/vcs/7999e2beb88d49c16df3019dc281fbfef947b52d6454ecb8905b12aea326f558: exit status 128:
	fatal: The remote end hung up unexpectedly

PIHolePort Variable Not working

So I am not sure if you have this parameter enabled or not, but from looks you only it to default to port 80.

Steps for Reproduction
Docker Config
So I read through the Readme and the some of the code, I found an option for (example) 'PIHolePort=8800'.

Same with both PIHOLE_PASSWORD as well.
As well as without the PIHolePort Parameter.
docker run
-e 'PIHOLE_HOSTNAME=192.168.1.200'
-e 'PIHOLE_API_TOKEN=BLAHBLAHMYTOKEN
-e 'INTERVAL=30s'
-e 'PIHolePort=8800'
-e 'PORT=9617'
-p 9617:9617
ekofr/pihole-exporter:latest

running ubuntu server 20.04 lts, docker 20.10.2
I am trying to self host both pihole and the exporter from the same docker.
I maybe totally a noob, but I think something is wrong.
But any help would be awesome, thanks.
Log:
But no matter which options I am putting in, as well as exposing the PIHolePort
2021/01/15 17:08:05 ------------------------------------
2021/01/15 17:08:05 - PI-Hole exporter configuration -
2021/01/15 17:08:05 ------------------------------------
2021/01/15 17:08:05 PIHoleProtocol : http
2021/01/15 17:08:05 PIHoleHostname : 192.168.1.200
2021/01/15 17:08:05 PIHolePort : 80
2021/01/15 17:08:05 Pi-Hole Authentication Method : PIHoleApiToken
2021/01/15 17:08:05 Port : 9617
2021/01/15 17:08:05 Interval : 30s
2021/01/15 17:08:05 ------------------------------------

JSON Import in Grafana not Working

When i Import the raw json in Grafana and select the Prometheus datasource there is no data. i double checked all.

image

and this is what i see when i edit a dashboard.. the datasource seems wrong there but why ?

image

Crashing/unable to start on docker v0.0.7

After updating from 0.0.6 to 0.0.7 (docker container) the application does no longer start.

Configuration is done via environment variables which have not been changed between the two versions. The following variables are set:
- PIHOLE_HOSTNAME=pihole
- PIHOLE_PASSWORD="password"
- INTERVAL=30s
- PORT=9617

Steps for Reproduction

  1. Update from 0.0.6 to 0.0.7
  2. Start container
  3. Error appears

Expected behavior:
Application starts successfully

Actual behavior:
Application does not start or crashes on start with the following error message:
standard_init_linux.go:211: exec user process caused "exec format error" pihole exporter

Platforms:
Docker on Ubuntu

Versions:
Docker version 19.03.5, build 633a0ea838
pihole-exporter version 0.0.7

Exporter isn't showing any data

I setup the exporter as a Docker container and Prometheus is showing the target as up. However, when I click the target metrics page, I see 0's for everything.

pihole_status{hostname="192.168.15.15"} 0

Pihole is indeed up. I've used both the API key and the password in the exporter and the result is the same.

No Data Scraped by Prometheus

After spending several hours trying to get this script working I'm at a loss as to what's going wrong.

Running Docker on RPi3 w/ latest Rasbian Lite. (Though I want to run both this container and Prometheus on a separate server, running it on the pi to eliminate variables)
Deployment:

$ API_TOKEN=$(awk -F= -v key="WEBPASSWORD" '$1==key {print $2}' /etc/pihole/setupVars.conf)
$ docker run --name pihole-exporter -d -p9617:9617 -e 'PIHOLE_HOSTNAME=192.168.1.13' -e "PIHOLE_API_TOKEN=$API_TOKEN" -e 'PORT=9617' -e 'INTERVAL=10s' ekofr/pihole-exporter:0.0.9
$ docker run --name prometheus -d -p 9090:9090 --mount source=prometheus,target=/etc/prometheus/ prom/prometheus

prometheus.yml:

# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
  - static_configs:
    - targets:
      # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
    - targets: ['localhost:9090']

  - job_name: 'pihole'
    honor_timestamps: true
    metrics_path: /metrics
    scheme: http
    static_configs:
    - targets: ['localhost:9617']

Not all metrics available in Prometheus

I recognized that just some metrics are available in Prometheus instead of the whole list which is provided here. This causes that some panels from the Dashboard are not working. Is it possible to add those metrics afterwards?

grafik

Unable to login to PI-Hole, got a HTTP status code response '307' instead of '302'

This was working a few weeks back, i am not sure what has changed. I have tried both via IP and DNS, the only redirect if you follow this in a browser/developer tools is a 301, not a 307.

pi-hole-exporter    | 2019-08-06T07:51:48.240888700Z 2019/08/06 07:51:48 ------------------------------------
pi-hole-exporter    | 2019-08-06T07:51:48.241230421Z 2019/08/06 07:51:48 -  PI-Hole exporter configuration  -
pi-hole-exporter    | 2019-08-06T07:51:48.241254412Z 2019/08/06 07:51:48 ------------------------------------
pi-hole-exporter    | 2019-08-06T07:51:48.241261895Z 2019/08/06 07:51:48 PIHoleHostname : XXXX
pi-hole-exporter    | 2019-08-06T07:51:48.241268251Z 2019/08/06 07:51:48 PIHolePassword : XXXX
pi-hole-exporter    | 2019-08-06T07:51:48.241435407Z 2019/08/06 07:51:48 Port : 8053
pi-hole-exporter    | 2019-08-06T07:51:48.241697784Z 2019/08/06 07:51:48 Interval : 10s
pi-hole-exporter    | 2019-08-06T07:51:48.241800713Z 2019/08/06 07:51:48 ------------------------------------
pi-hole-exporter    | 2019-08-06T07:51:48.241934490Z 2019/08/06 07:51:48 New Prometheus metric registered: domains_blocked
pi-hole-exporter    | 2019-08-06T07:51:48.242049222Z 2019/08/06 07:51:48 New Prometheus metric registered: dns_queries_today
pi-hole-exporter    | 2019-08-06T07:51:48.242157463Z 2019/08/06 07:51:48 New Prometheus metric registered: ads_blocked_today
pi-hole-exporter    | 2019-08-06T07:51:48.242262395Z 2019/08/06 07:51:48 New Prometheus metric registered: ads_percentag_today
pi-hole-exporter    | 2019-08-06T07:51:48.242359561Z 2019/08/06 07:51:48 New Prometheus metric registered: unique_domains
pi-hole-exporter    | 2019-08-06T07:51:48.242668975Z 2019/08/06 07:51:48 New Prometheus metric registered: queries_forwarded
pi-hole-exporter    | 2019-08-06T07:51:48.242832429Z 2019/08/06 07:51:48 New Prometheus metric registered: queries_cached
pi-hole-exporter    | 2019-08-06T07:51:48.243009119Z 2019/08/06 07:51:48 New Prometheus metric registered: clients_ever_seen
pi-hole-exporter    | 2019-08-06T07:51:48.243182319Z 2019/08/06 07:51:48 New Prometheus metric registered: unique_clients
pi-hole-exporter    | 2019-08-06T07:51:48.243341386Z 2019/08/06 07:51:48 New Prometheus metric registered: dns_queries_all_types
pi-hole-exporter    | 2019-08-06T07:51:48.243514470Z 2019/08/06 07:51:48 New Prometheus metric registered: reply
pi-hole-exporter    | 2019-08-06T07:51:48.243689330Z 2019/08/06 07:51:48 New Prometheus metric registered: top_queries
pi-hole-exporter    | 2019-08-06T07:51:48.243860447Z 2019/08/06 07:51:48 New Prometheus metric registered: top_ads
pi-hole-exporter    | 2019-08-06T07:51:48.244019047Z 2019/08/06 07:51:48 New Prometheus metric registered: top_sources
pi-hole-exporter    | 2019-08-06T07:51:48.244193067Z 2019/08/06 07:51:48 New Prometheus metric registered: forward_destinations
pi-hole-exporter    | 2019-08-06T07:51:48.244364824Z 2019/08/06 07:51:48 New Prometheus metric registered: querytypes
pi-hole-exporter    | 2019-08-06T07:51:48.244522514Z 2019/08/06 07:51:48 New Prometheus metric registered: status
pi-hole-exporter    | 2019-08-06T07:51:48.245078558Z 2019/08/06 07:51:48 Starting HTTP server
pi-hole-exporter    | 2019-08-06T07:51:58.251806682Z 2019/08/06 07:51:58 Unable to login to PI-Hole, got a HTTP status code response '307' instead of '302'

No data in Grafana / Follow up your advise

I just installed on my Pi4 pihole as usal, installed prometheus as well go and going through your readme. Everything is running, but there is no way to see data in grafana. Can you help me? What do i need configure on grafana site? What's wrong, what must i check?

Bildschirmfoto 2020-03-16 um 18 02 01
Bildschirmfoto 2020-03-16 um 18 04 11

pihole login failing when no login required

pihole is setup with no user/pass. Starting exporter without a password but exporter appears to be trying to login anyway and getting confused?

pi@PIHOLE:~ $ pihole_exporter-linux-arm
2019/05/10 11:57:27 ------------------------------------
2019/05/10 11:57:27 - PI-Hole exporter configuration -
2019/05/10 11:57:27 ------------------------------------
2019/05/10 11:57:27 PIHoleHostname : 127.0.0.1
2019/05/10 11:57:27 PIHolePassword :
2019/05/10 11:57:27 Port : 9311
2019/05/10 11:57:27 Interval : 10s
2019/05/10 11:57:27 ------------------------------------
2019/05/10 11:57:27 New Prometheus metric registered: domains_blocked
2019/05/10 11:57:27 New Prometheus metric registered: dns_queries_today
2019/05/10 11:57:27 New Prometheus metric registered: ads_blocked_today
2019/05/10 11:57:27 New Prometheus metric registered: ads_percentag_today
2019/05/10 11:57:27 New Prometheus metric registered: unique_domains
2019/05/10 11:57:27 New Prometheus metric registered: queries_forwarded
2019/05/10 11:57:27 New Prometheus metric registered: queries_cached
2019/05/10 11:57:27 New Prometheus metric registered: clients_ever_seen
2019/05/10 11:57:27 New Prometheus metric registered: unique_clients
2019/05/10 11:57:27 New Prometheus metric registered: dns_queries_all_types
2019/05/10 11:57:27 New Prometheus metric registered: reply
2019/05/10 11:57:27 New Prometheus metric registered: top_queries
2019/05/10 11:57:27 New Prometheus metric registered: top_ads
2019/05/10 11:57:27 New Prometheus metric registered: top_sources
2019/05/10 11:57:27 New Prometheus metric registered: forward_destinations
2019/05/10 11:57:27 New Prometheus metric registered: querytypes
2019/05/10 11:57:27 New Prometheus metric registered: status
2019/05/10 11:57:27 Starting HTTP server
2019/05/10 11:57:38 Unable to login to PI-Hole, got a HTTP status code response '200' instead of '302'

[F/R] add healthcheck to dockerfile

Have you considered adding a simple healthcheck to the Dockerfile?

I think to do this you will need to change the base image from scratch to alpine, which will increase the resulting final image (on my system it more than tripled it), and I have an appreciation for keeping this as simple and minimal as possible. Also I am not super familiar with the ins and outs of exporters so I'm not really sure how much value a healthcheck will even add in this case.

The other possibility would be to add a built-in check function to the pihole-exporter itself, which might keep the bloat down a bit.

pvn@gyarados /home/pvn> docker image ls | grep pihole-exporter
pvnovarese/pihole-exporter         latest              16e60d69390e        15 minutes ago      8.07MB
ekofr/pihole-exporter              latest              35e4393afb6f        2 weeks ago         2.45MB

Anyway, all I did is change

ARG IMAGE=alpine

and then add

HEALTHCHECK CMD wget --spider http://127.0.0.1:9617/metrics || exit 1

I can submit a PR if you're interested in doing this.

random values in dashboard

It's the first time I'm working with Grafana, so probably it's my fault

Steps for Reproduction

  1. launch docker-compose -f pihole.yml up -d
  2. launch docker-compose -f grafana.yml up -d
  3. import this dashboard
  4. localhost:3000/thisdashboard

Expected behavior:
Working dashboard

Actual behavior:
random values in dashboard

image

edit: fixed: prometheus was not setup correctly

docker: from scratch image?

The current final image starts from alpine.

Wouldn't it work with a FROM scratch, thus greatly reducing the production image size?

Pi-Hole Exporter Dashboard Doesn't Show Any Data By Default

I am unable to get the PI-Hole Exporter Dashboard to display any data when using this project. I realize that the dashboard mentioned is not this project specifically, but perhaps you would know how to resolve this issue, as you also wrote the dashboard haha.

I've tried importing the dashboard by id (10176) and also by using its JSON and still have not been successful.

My setup may differ from yours, as my Grafana and Prometheus installs are dockerized on some machine A and my pihole exporter is on some machine B. I've attempted to configure the JSON to point at the machine B, where the pihole exporter is running and have been successful at getting my own graphs to display, but not the ones in your dashboard.

Any thoughts or advice would be greatly appreciated, as your dashboard looks lovely.

Missing Some Stats

It seems that no data is being generated by the exporter for 'DNS Query Types', 'Top queries', 'Top ads domains', and 'Forward destinations' in the dashboard. When I go to my http://[pihole]/metrics I see that these values are NOT there, but when I start the service or run the exporter manually, they do show up in the `ist:

2020/04/13` 06:48:38 ------------------------------------
2020/04/13 06:48:38 -  PI-Hole exporter configuration  -
2020/04/13 06:48:38 ------------------------------------
2020/04/13 06:48:38 PIHoleHostname : IP_ADDRESS_HERE
2020/04/13 06:48:38 PIHolePassword : 
2020/04/13 06:48:38 Port : 9617
2020/04/13 06:48:38 Interval : 10s
2020/04/13 06:48:38 ------------------------------------
2020/04/13 06:48:38 New Prometheus metric registered: domains_blocked
2020/04/13 06:48:38 New Prometheus metric registered: dns_queries_today
2020/04/13 06:48:38 New Prometheus metric registered: ads_blocked_today
2020/04/13 06:48:38 New Prometheus metric registered: ads_percentag_today
2020/04/13 06:48:38 New Prometheus metric registered: unique_domains
2020/04/13 06:48:38 New Prometheus metric registered: queries_forwarded
2020/04/13 06:48:38 New Prometheus metric registered: queries_cached
2020/04/13 06:48:38 New Prometheus metric registered: clients_ever_seen
2020/04/13 06:48:38 New Prometheus metric registered: unique_clients
2020/04/13 06:48:38 New Prometheus metric registered: dns_queries_all_types
2020/04/13 06:48:38 New Prometheus metric registered: reply
**2020/04/13 06:48:38 New Prometheus metric registered: top_queries**
**2020/04/13 06:48:38 New Prometheus metric registered: top_ads**
2020/04/13 06:48:38 New Prometheus metric registered: top_sources
**2020/04/13 06:48:38 New Prometheus metric registered: forward_destinations**
**2020/04/13** 06:48:38 New Prometheus metric registered: querytypes**
2020/04/13 06:48:38 New Prometheus metric registered: status
2020/04/13 06:48:38 Starting HTTP server
2020/04/13 06:48:48 New tick of statistics: X ads blocked / X total DNS queries

I can't change port

I'm having trouble get the docker container talking to my pi-hole container

When its running I get this error

2021/01/27 21:44:25 Unable to unmarshal PI-Hole statistics to statistics struct model invalid character '<' looking for beginning of value | stderr

I think the problem is its trying to access my pi-hole management on port 80 but I'm using 8888

How can you change that please

Unable to login to PI-Hole, got a HTTP status code response '200' instead of '302'

I'm running Pi Hole v4.3.2, and pihole-exporter 0.0.4 from docker hub (ekofr/pihole-exporter:0.0.4).

I have a password set for pihole.

2019/09/27 11:21:39 ------------------------------------
2019/09/27 11:21:39 - PI-Hole exporter configuration -
2019/09/27 11:21:39 ------------------------------------
2019/09/27 11:21:39 PIHoleHostname : pihole.hidden
2019/09/27 11:21:39 PIHolePassword : supersecurepassword
2019/09/27 11:21:39 Port : 9617
2019/09/27 11:21:39 Interval : 30s
2019/09/27 11:21:39 ------------------------------------
2019/09/27 11:21:39 New Prometheus metric registered: domains_blocked
2019/09/27 11:21:39 New Prometheus metric registered: dns_queries_today
2019/09/27 11:21:39 New Prometheus metric registered: ads_blocked_today
2019/09/27 11:21:39 New Prometheus metric registered: ads_percentag_today
2019/09/27 11:21:39 New Prometheus metric registered: unique_domains
2019/09/27 11:21:39 New Prometheus metric registered: queries_forwarded
2019/09/27 11:21:39 New Prometheus metric registered: queries_cached
2019/09/27 11:21:39 New Prometheus metric registered: clients_ever_seen
2019/09/27 11:21:39 New Prometheus metric registered: unique_clients
2019/09/27 11:21:39 New Prometheus metric registered: dns_queries_all_types
2019/09/27 11:21:39 New Prometheus metric registered: reply
2019/09/27 11:21:39 New Prometheus metric registered: top_queries
2019/09/27 11:21:39 New Prometheus metric registered: top_ads
2019/09/27 11:21:39 New Prometheus metric registered: top_sources
2019/09/27 11:21:39 New Prometheus metric registered: forward_destinations
2019/09/27 11:21:39 New Prometheus metric registered: querytypes
2019/09/27 11:21:39 New Prometheus metric registered: status
2019/09/27 11:21:39 Starting HTTP server
2019/09/27 11:22:09 Unable to login to PI-Hole, got a HTTP status code response '200' instead of '302'

No Data Source in Dashboard

Hey,

I cannot set the source in grafana and the exporter run only in the live mode but not in the backend.

Best regards

remove INTERVAL

Please describe the a concise description and fill out the details below. It will help others efficiently understand your request and get to an answer instead of repeated back and forth. Providing a minimal, complete and verifiable example will further increase your chances that someone can help.

Steps for Reproduction

  1. Just launch exporter

Expected behavior:

exporter is scraping data from pihole when prometheus requests it.

Actual behavior:

exporter is polling data from pihole with on custom schedule set by INTERVAL variable

Platforms:

all

Versions:

all

More info:

According to prometheus docs:

Metrics should only be pulled from the application when Prometheus scrapes them, exporters should not perform scrapes based on their own timers

Add a configuration file

The community will highly benefit from having a static configuration file in-which you will be able to set all current environmental variables.

I am currently running version v0.0.8

Memory leak

Please describe the a concise description and fill out the details below. It will help others efficiently understand your request and get to an answer instead of repeated back and forth. Providing a minimal, complete and verifiable example will further increase your chances that someone can help.

Steps for Reproduction

  1. Set following variables:
    • INTERVAL=15s
    • PIHOLE_HOSTNAME=<redacted>
    • PIHOLE_PASSWORD=<redacted>
  2. Launch with default arguments
  3. Wait
  4. Go to prometheus and check exporter memory consumpiton

Expected behavior:

Exporter is using less memory than pihole itself. After 3 days it is eating 250Mb of memory, which is a bit problematic on raspberry pi.

Actual behavior:

Exporter is leaking memory and eating more than 2x pihole memory after just 3 days.

Platforms:

Include browser, operating system and respective versions

  • Chrome (why does it matter for exporter???)
  • raspbian buster
  • pihole 4.4

Versions:

Which versions are you running?

0.0.6

Additional info:

Pihole and exporter are running in containers.

Exporter is gathering metrics correctly.

Prometheus query screenshot:
Screenshot_20200509_172223

curl to 9617 produces a "404 page not found", no data is collected

Please describe the a concise description and fill out the details below. It will help others efficiently understand your request and get to an answer instead of repeated back and forth. Providing a minimal, complete and verifiable example will further increase your chances that someone can help.

Steps for Reproduction


I tried running the exporter on the same machine as the pi.   The same exact results were observed.  The exporter runs, attaches, and prints the stats on the screen, but when you use CURL to check the port, 404 page not found is displayed.  

I tried running the docker version from the grafana machine and here is the result:

# docker run -p 9617:9617 -d  -e 'PIHOLE_HOSTNAME=192.168.1.2'   -e 'PIHOLE_PASSWORD=secret-password'   -e 'INTERVAL=10s'   -e 'PORT=9617'   ekofr/pihole-exporter:latest
# $ docker logs c84b571f15b0
2020/03/18 18:33:38 ------------------------------------
2020/03/18 18:33:38 -  PI-Hole exporter configuration  -
2020/03/18 18:33:38 ------------------------------------
2020/03/18 18:33:38 PIHoleHostname : 192.168.1.2
2020/03/18 18:33:38 PIHolePassword :  secret-password
2020/03/18 18:33:38 Port : 9617
2020/03/18 18:33:38 Interval : 10s
2020/03/18 18:33:38 ------------------------------------
2020/03/18 18:33:38 New Prometheus metric registered: domains_blocked
2020/03/18 18:33:38 New Prometheus metric registered: dns_queries_today
2020/03/18 18:33:38 New Prometheus metric registered: ads_blocked_today
2020/03/18 18:33:38 New Prometheus metric registered: ads_percentag_today
2020/03/18 18:33:38 New Prometheus metric registered: unique_domains
2020/03/18 18:33:38 New Prometheus metric registered: queries_forwarded
2020/03/18 18:33:38 New Prometheus metric registered: queries_cached
2020/03/18 18:33:38 New Prometheus metric registered: clients_ever_seen
2020/03/18 18:33:38 New Prometheus metric registered: unique_clients
2020/03/18 18:33:38 New Prometheus metric registered: dns_queries_all_types
2020/03/18 18:33:38 New Prometheus metric registered: reply
2020/03/18 18:33:38 New Prometheus metric registered: top_queries
2020/03/18 18:33:38 New Prometheus metric registered: top_ads
2020/03/18 18:33:38 New Prometheus metric registered: top_sources
2020/03/18 18:33:38 New Prometheus metric registered: forward_destinations
2020/03/18 18:33:38 New Prometheus metric registered: querytypes
2020/03/18 18:33:38 New Prometheus metric registered: status
2020/03/18 18:33:38 Starting HTTP server
2020/03/18 18:33:48 New tick of statistics: 8946 ads blocked / 66293 total DNS queries
2020/03/18 18:33:58 New tick of statistics: 8947 ads blocked / 66294 total DNS queries
2020/03/18 18:34:08 New tick of statistics: 8947 ads blocked / 66302 total DNS queries
2020/03/18 18:34:18 New tick of statistics: 8948 ads blocked / 66307 total DNS queries
2020/03/18 18:34:28 New tick of statistics: 8949 ads blocked / 66310 total DNS queries
2020/03/18 18:34:38 New tick of statistics: 8952 ads blocked / 66313 total DNS queries
# curl -v localhost:9617/index.html 
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9617 (#0)
> GET /index.html HTTP/1.1
> Host: localhost:9617
> User-Agent: curl/7.61.1
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< Content-Type: text/plain; charset=utf-8
< X-Content-Type-Options: nosniff
< Date: Wed, 18 Mar 2020 18:34:26 GMT
< Content-Length: 19
< 
404 page not found
* Connection #0 to host localhost left intact

Expected behavior:

From what I understand the output of the curl command should be some JSON not a 404.

Actual behavior:

Produces a 404 with "404 page not found" as the content of the body.

Platforms:

Pi 4B

Include browser, operating system and respective versions

Versions:
Raspbian GNU/Linux 9 (stretch)

$ pihole -v
Pi-hole version is v4.4 (Latest: v4.4)
AdminLTE version is v4.3.3 (Latest: v4.3.3)
FTL version is v4.3.1 (Latest: v4.3.1)

Which versions are you running?

0.0.8 from the release page here ... arm varient.

Prevent PIHolePassword from being printed

Currently when ran, the exporter prints all supplied environmental variable which includes the password.

Bear in mind that the following password is also used as the login password.

Where is prometheus.yml?

I downloaded the binary and then ran:

./pihole_exporter-linux-amd64 -pihole_hostname 192.168.1.202 -pihole_password passs!

Which then works and reports:
2020/03/22 13:12:32 New tick of statistics: 3249 ads blocked / 32319 total DNS queries
Every 10s.

However in the read me we are told then to update prometheus.yml - I have searched my server for this file and just don't see it anywhere. Please could you tell me where it is? \\

I'll then do a new PR to update the readme as it really isn't clear how we add the job.

Thanks for the great work!

arm64 docker images don't appear to work on raspberry pi 4

Steps for Reproduction

  1. deploy ekofr/pihole-exporter:arm64 to kubernetes (on raspberry pi 4)

Expected behavior:

pihole-exporter runs without error

Actual behavior:

pihole crashes with: standard_init_linux.go:211: exec user process caused "exec format error"
(typical error when trying to run non arm images on arm arch)

Platforms:

raspberry pi 4
Ubuntu 20.04.1 LTS 64-bit
k3s

Versions:
arm64 docker image

Unable to start the exporter

I'm sure I just haven't done something right - but I'm unable to even start the exporter.

I have installed Golang 1.12, and then removed and installed 1.11. So currently on 1.11 but the issue occurs on both.

Downloaded the pihole_exporter-linux-amd64 file as I am using Ubuntu Server however when I do ./pihole_exporter-linux-amd64 I get the error message "command not found" - I'm sure i've missed something very basic, I'm not very cluey with this kind of stuff.

I am also unable to run the GO111MODULE=on go mod vendor as I get a 'cannot find main module' error so maybe it's a golang issue? All help is appreciated.

Regards

Metrics missing when run as system

Hi

Running on pi, Co hosted with pihole,

When running as system, some metrics are not being recieved, but when ran on commandline with ./pihole_exporter-linux-arm -pihole_password PASSWORD all metrics come through ok

I think its because when ran as system the -pihole_password tag isnt being passed from reading through a few closed tickets, However I am not sure where/how that should be done?

Thanks for any help in advance!

Sawtooth Pattern on dns query counts

I am trying to verify the behavior of this exporter for both pihole_ads_blocked_today and pihole_dns_queries_all_types where I am seeing a sawtooth pattern that drops 2-5k every hour.

Steps for Reproduction

Use version 0.0.10 (latest at the current time) on docker hub for arm v7.

Expected behavior:
A steady increase in total ads blocked today

Actual behavior:
I have a graph in grafana for pihole_ads_blocked_today. I get a sawtooth pattern that drops about 500 every hour. This results in a sawtooth pattern.

Platforms:

ARMv7 (Raspberry Pi 3B+)

Versions:
0.0.10 of exporter
5.0 of pi-hole

image

docker - 404 page not found

ran my docker container using this command:
docker run -d --name pihole_exporter -e 'PIHOLE_HOSTNAME=192.168.138.122' -e 'PIHOLE_PASSWORD=[redacted]' -e 'INTERVAL=30s' -e 'PORT=9617' -p 9617:9617 ekofr/pihole-exporter

but when i go to 192.168.138.124:9617 (my docker machine) i get a 404 page not found

Docker Hub Image ekofr/pihole-exporter:arm fails to run on Pi 3B+ (v7 32bit)

running the image official image ekofr/pihole-exporter:arm results in
pihole-exporter | standard_init_linux.go:211: exec user process caused "exec format error"
Steps for Reproduction

run the image

Expected behavior:

Container starts

Actual behavior:

Startup fails with
pihole-exporter | standard_init_linux.go:211: exec user process caused "exec format error"

Platforms:
Linux raspberrypi 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l GNU/Linux

Client: Docker Engine - Community
Version: 19.03.12
API version: 1.40
Go version: go1.13.10
Git commit: 48a6621
Built: Mon Jun 22 15:53:41 2020
OS/Arch: linux/arm
Experimental: false

Server: Docker Engine - Community
Engine:
Version: 19.03.12
API version: 1.40 (minimum version 1.12)
Go version: go1.13.10
Git commit: 48a6621
Built: Mon Jun 22 15:47:34 2020
OS/Arch: linux/arm
Experimental: true
containerd:
Version: 1.2.13
GitCommit: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc:
Version: 1.0.0-rc10
GitCommit: dc9208a3303feef5b3839f4323d9beb36df0a9dd
docker-init:
Version: 0.18.0
GitCommit: fec3683

Versions:

Which versions are you running?
ekofr/pihole-exporter:arm

Suggest Changing Port Number

The read me currently provides an example docker command that utilises port 9311. According to https://github.com/prometheus/prometheus/wiki/Default-port-allocations however 9311 is the "registered" port number for IOTA Exporter (https://github.com/crholliday/iota-prom-exporter).

Whilst this doesn't materially affect anything it would lead to a conflict if both are used on the same host. Can I suggest therefore adding an entry into that wiki specifically for this product and updating the read me to reflect that same? I'd be happy to submit a PR for it.

Thanks.

Docker deployment - memory leak

I noticed a memory consumption of 1.3GB for piholeexporter last I checked my monitoring. After restarting, that dropped to 20MB, which promply started climbing steadily again. In 3 hours it went from 29MB to 37MB. I guess there's a memory leak?

I'm using the following docker-compose setup (pulled and checked that the latest also had the behaviour):

  piholeexporter:
    container_name: piholeexporter
    image: ekofr/pihole-exporter:latest
    depends_on:
      - pihole
    restart: unless-stopped
    environment:
      PIHOLE_HOSTNAME: 'x'
      PIHOLE_PASSWORD: 'x'
      INTERVAL: '30s'
      PORT: '9617'

OLD DATA FROM PIHOLE STILL DISPLAYS AFTER FLUSHING PIHOLE

Using a Prometheus DB and using your PI Hole stats graph. When the data is flushed flush from PI Hole via the web gui your graphs are still reporting data (old) that no longer exists in Pi Hole. Is there some setting I am maybe missing in Prometheus? The PI hole top sources is one for example. I have tried setting the data time on the graph to 5 minutes to ensure it is picking up only the last 5 minutes of data after the PI hole flush. The one I mentioned above as an example still shows old data. Some lag or something in updating data in the Prometheus DB maybe?...

In addition has there been any changes with new PI hole version 5 to use the new local DNS records?

Docker container crashing

The docker container crashes due to a timeout accessing dockerized pihole. The pihole container works, and is accessible on 192.168.1.1:80, so not sure what the problem is for pihole_exporter. Maybe host networking mode and the elevated privlages pihole needs for DHCP?

Steps for Reproduction

docker-compose.yaml:

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    network_mode: host
    environment:
      TZ: 'America/New_York'
      WEBPASSWORD: 'super-secret'
      DNS1: "1.1.1.1"
      DNS2: "1.0.0.1"
      DNSSEC: "True"
      ServerIP: "192.168.1.1"
      INTERFACE: "eth0"
      DNSMASQ_LISTENING: "eth0"
    # Volumes store your data between container upgrades
    volumes:
       - '/srv/pihole/config/:/etc/pihole/'
       - '/srv/pihole/dnsmasq.d/:/etc/dnsmasq.d/'
    dns:
      - 127.0.0.1
      - 1.1.1.1
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

 pihole_exporter:
    container_name: pihole_exporter
    image: ekofr/pihole-exporter:latest
    ports:
      - "9617:9617"
    environment:
      PIHOLE_HOSTNAME: 192.168.1.1
      PIHOLE_PASSWORD: super-secret
      INTERVAL: 30s
  1. Run it
docker-compose up -d
  1. After a few seconds pihole_exporter crashes.

Expected behavior:

pihole_exporter is started

Actual behavior:

It crashes. Following are in the docker logs:

2020/04/16 23:26:15 ------------------------------------
2020/04/16 23:26:15 -  PI-Hole exporter configuration  -
2020/04/16 23:26:15 ------------------------------------
2020/04/16 23:26:15 PIHoleHostname : 192.168.1.1
2020/04/16 23:26:15 Port : 9617
2020/04/16 23:26:15 Interval : 30s
2020/04/16 23:26:15 ------------------------------------
2020/04/16 23:26:15 New Prometheus metric registered: domains_blocked
2020/04/16 23:26:15 New Prometheus metric registered: dns_queries_today
2020/04/16 23:26:15 New Prometheus metric registered: ads_blocked_today
2020/04/16 23:26:15 New Prometheus metric registered: ads_percentag_today
2020/04/16 23:26:15 New Prometheus metric registered: unique_domains
2020/04/16 23:26:15 New Prometheus metric registered: queries_forwarded
2020/04/16 23:26:15 New Prometheus metric registered: queries_cached
2020/04/16 23:26:15 New Prometheus metric registered: clients_ever_seen
2020/04/16 23:26:15 New Prometheus metric registered: unique_clients
2020/04/16 23:26:15 New Prometheus metric registered: dns_queries_all_types
2020/04/16 23:26:15 New Prometheus metric registered: reply
2020/04/16 23:26:15 New Prometheus metric registered: top_queries
2020/04/16 23:26:15 New Prometheus metric registered: top_ads
2020/04/16 23:26:15 New Prometheus metric registered: top_sources
2020/04/16 23:26:15 New Prometheus metric registered: forward_destinations
2020/04/16 23:26:15 New Prometheus metric registered: querytypes
2020/04/16 23:26:15 New Prometheus metric registered: status
2020/04/16 23:26:15 Starting HTTP server
2020/04/16 23:27:15 An error has occured during login to PI-Hole: Post "http://192.168.1.1/admin/index.php?login": dial tcp 192.168.1.1:80: i/o timeout
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x38 pc=0x7a7a52]

goroutine 34 [running]:
net/http.(*Response).Cookies(...)
	/usr/local/go/src/net/http/response.go:126
github.com/eko/pihole-exporter/internal/pihole.(*Client).getPHPSessionID(0xc00019a770, 0xc000038790, 0xc000038701)
	/go/src/github.com/eko/pihole-exporter/internal/pihole/client.go:121 +0x512
github.com/eko/pihole-exporter/internal/pihole.(*Client).Scrape(0xc00019a770)
	/go/src/github.com/eko/pihole-exporter/internal/pihole/client.go:50 +0x1dd
created by main.initPiholeClient
	/go/src/github.com/eko/pihole-exporter/main.go:37 +0x75

Platforms:

Running on Alpine Linux 3.11, docker 19.03.5

Versions:

latest

Ubuntu 20.04

Good Evening,

When I try and run it I get the following error... thoughts?

2020/08/12 11:29:12 Starting HTTP server
2020/08/12 11:29:22 An error has occured during retrieving PI-Hole statistics Get "http://127.0.0.1:80/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&jsonForceObject": dial tcp 127.0.0.1:80: connect: connection refused
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x7a9426]

goroutine 25 [running]:
github.com/eko/pihole-exporter/internal/pihole.(*Client).getStatistics(0xc0000d83f0, 0xc00003a790)
	/go/src/github.com/eko/pihole-exporter/internal/pihole/client.go:163 +0x2f6
github.com/eko/pihole-exporter/internal/pihole.(*Client).Scrape(0xc0000d83f0)
	/go/src/github.com/eko/pihole-exporter/internal/pihole/client.go:61 +0x83
created by main.initPiHoleClient
	/go/src/github.com/eko/pihole-exporter/main.go:37 +0xc0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.