Compare commits

..

No commits in common. "master" and "v0.4.0" have entirely different histories.

13 changed files with 97 additions and 100 deletions

View file

@ -1,6 +1,6 @@
# Contributing # Contributing
Pi-hole exporter is an open source project, completely opened to be a community-driven project. PI-Hole exporter is an open source project, completely opened to be a community-driven project.
If you'd like to contribute, you are free to do so. If you'd like to contribute, you are free to do so.

View file

@ -2,7 +2,7 @@ ARG IMAGE=scratch
ARG OS=linux ARG OS=linux
ARG ARCH=amd64 ARG ARCH=amd64
FROM golang:1.21.2-alpine3.17 as builder FROM golang:1.20.1-alpine3.17 as builder
WORKDIR /go/src/github.com/eko/pihole-exporter WORKDIR /go/src/github.com/eko/pihole-exporter
COPY . . COPY . .

View file

@ -1,10 +1,10 @@
# Pi-hole Prometheus Exporter # PI-Hole Prometheus Exporter
![Build/Push (master)](https://github.com/eko/pihole-exporter/workflows/Build/Push%20(master)/badge.svg) ![Build/Push (master)](https://github.com/eko/pihole-exporter/workflows/Build/Push%20(master)/badge.svg)
[![GoDoc](https://godoc.org/github.com/eko/pihole-exporter?status.png)](https://godoc.org/github.com/eko/pihole-exporter) [![GoDoc](https://godoc.org/github.com/eko/pihole-exporter?status.png)](https://godoc.org/github.com/eko/pihole-exporter)
[![GoReportCard](https://goreportcard.com/badge/github.com/eko/pihole-exporter)](https://goreportcard.com/report/github.com/eko/pihole-exporter) [![GoReportCard](https://goreportcard.com/badge/github.com/eko/pihole-exporter)](https://goreportcard.com/report/github.com/eko/pihole-exporter)
This is a Prometheus exporter for [Pi-hole](https://pi-hole.net/)'s Raspberry PI ad blocker. This is a Prometheus exporter for [PI-Hole](https://pi-hole.net/)'s Raspberry PI ad blocker.
![Grafana dashboard](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard.jpg) ![Grafana dashboard](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard.jpg)
@ -95,7 +95,7 @@ If port, protocol and API token/password is the same for all instances, you can
``` ```
$ docker run \ $ docker run \
-e 'PIHOLE_PROTOCOL=http" \ -e 'PIHOLE_PROTOCOL=,http" \
-e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \ -e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
-e "PIHOLE_API_TOKEN=$API_TOKEN" \ -e "PIHOLE_API_TOKEN=$API_TOKEN" \
-e "PIHOLE_PORT=8080" \ -e "PIHOLE_PORT=8080" \
@ -143,7 +143,7 @@ $ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_api_token $API_TOKEN
```bash ```bash
2019/05/09 20:19:52 ------------------------------------ 2019/05/09 20:19:52 ------------------------------------
2019/05/09 20:19:52 - Pi-hole exporter configuration - 2019/05/09 20:19:52 - PI-Hole exporter configuration -
2019/05/09 20:19:52 ------------------------------------ 2019/05/09 20:19:52 ------------------------------------
2019/05/09 20:19:52 PIHoleHostname : 192.168.1.10 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 PIHolePassword : azerty
@ -183,21 +183,18 @@ scrape_configs:
## Available CLI options ## Available CLI options
```bash ```bash
# Hostname of the host(s) where Pi-hole is installed # Hostname of the host(s) where PI-Hole is installed
-pihole_hostname string (optional) (default "127.0.0.1") -pihole_hostname string (optional) (default "127.0.0.1")
# Password defined on the Pi-hole interface # Password defined on the PI-Hole interface
-pihole_password string (optional) -pihole_password string (optional)
# Timeout to connect and retrieve data from a Pi-hole instance # Timeout to connect and retrieve data from a Pi-Hole instance
-timeout duration (optional) (default 5s) -timeout duration (optional) (default 5s)
# WEBPASSWORD / api token defined on the Pi-hole interface at `/etc/pihole/setupVars.conf` # WEBPASSWORD / api token defined on the PI-Hole interface at `/etc/pihole/setupVars.conf`
-pihole_api_token string (optional) -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 to be used for the exporter
-port string (optional) (default "9617") -port string (optional) (default "9617")
``` ```
@ -217,12 +214,12 @@ scrape_configs:
| pihole_unique_clients | This represent the number of unique clients 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_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_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_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_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_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_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_querytypes | This represent the number of queries made by PI-Hole by type |
| pihole_status | This represent if Pi-hole is enabled | | pihole_status | This represent if PI-Hole is enabled |
## Pihole-Exporter Helm Chart ## Pihole-Exporter Helm Chart

View file

@ -24,8 +24,6 @@ type Config struct {
PIHolePort uint16 `config:"pihole_port"` PIHolePort uint16 `config:"pihole_port"`
PIHolePassword string `config:"pihole_password"` PIHolePassword string `config:"pihole_password"`
PIHoleApiToken string `config:"pihole_api_token"` PIHoleApiToken string `config:"pihole_api_token"`
BindAddr string `config:"bind_addr"`
Port uint16 `config:"port"`
} }
type EnvConfig struct { type EnvConfig struct {
@ -34,7 +32,6 @@ type EnvConfig struct {
PIHolePort []uint16 `config:"pihole_port"` PIHolePort []uint16 `config:"pihole_port"`
PIHolePassword []string `config:"pihole_password"` PIHolePassword []string `config:"pihole_password"`
PIHoleApiToken []string `config:"pihole_api_token"` PIHoleApiToken []string `config:"pihole_api_token"`
BindAddr string `config:"bind_addr"`
Port uint16 `config:"port"` Port uint16 `config:"port"`
Timeout time.Duration `config:"timeout"` Timeout time.Duration `config:"timeout"`
} }
@ -46,7 +43,6 @@ func getDefaultEnvConfig() *EnvConfig {
PIHolePort: []uint16{80}, PIHolePort: []uint16{80},
PIHolePassword: []string{}, PIHolePassword: []string{},
PIHoleApiToken: []string{}, PIHoleApiToken: []string{},
BindAddr: "0.0.0.0",
Port: 9617, Port: 9617,
Timeout: 5 * time.Second, Timeout: 5 * time.Second,
} }
@ -194,7 +190,7 @@ func (c Config) PIHoleLoginURL() string {
func (c EnvConfig) show() { func (c EnvConfig) show() {
val := reflect.ValueOf(&c).Elem() val := reflect.ValueOf(&c).Elem()
log.Info("------------------------------------") log.Info("------------------------------------")
log.Info("- Pi-hole exporter configuration -") log.Info("- PI-Hole exporter configuration -")
log.Info("------------------------------------") log.Info("------------------------------------")
log.Info("Go version: ", runtime.Version()) log.Info("Go version: ", runtime.Version())
for i := 0; i < val.NumField(); i++ { for i := 0; i < val.NumField(); i++ {
@ -213,6 +209,6 @@ func (c EnvConfig) show() {
func showAuthenticationMethod(name string, length int) { func showAuthenticationMethod(name string, length int) {
if length > 0 { if length > 0 {
log.Info(fmt.Sprintf("Pi-hole Authentication Method : %s", name)) log.Info(fmt.Sprintf("Pi-Hole Authentication Method : %s", name))
} }
} }

20
go.mod
View file

@ -4,25 +4,25 @@ go 1.20
require ( require (
github.com/heetch/confita v0.10.0 github.com/heetch/confita v0.10.0
github.com/prometheus/client_golang v1.17.0 github.com/prometheus/client_golang v1.14.0
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.0
github.com/stretchr/testify v1.8.4 github.com/stretchr/testify v1.8.2
github.com/xonvanetta/shutdown v0.0.3 github.com/xonvanetta/shutdown v0.0.3
golang.org/x/net v0.16.0 golang.org/x/net v0.7.0
) )
require ( require (
github.com/beorn7/perks v1.0.1 // indirect github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/common v0.41.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect github.com/prometheus/procfs v0.9.0 // indirect
golang.org/x/sys v0.13.0 // indirect golang.org/x/sys v0.5.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
) )

48
go.sum
View file

@ -42,9 +42,10 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@ -95,8 +96,8 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@ -133,41 +134,44 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM= github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v1.17.0 h1:rl2sfwZMtSthVU752MqfjQozy7blglC+1SOtjMAMh+Q= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw=
github.com/prometheus/client_golang v1.17.0/go.mod h1:VeL+gMmOAxkS2IqfCq0ZmHSL+LjWfWDUmp1mBz9JgUY= github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 h1:v7DLqVdK4VrYkVD5diGdl4sxJurKJEMnODWRJlxV9oM= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20181126121408-4724e9255275/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= github.com/prometheus/common v0.41.0 h1:npo01n6vUlRViIj5fgwiK8vlNIh8bnoxqh3gypKsyAw=
github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/common v0.41.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
@ -194,8 +198,8 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.16.0 h1:7eBu7KsSvFDtSXUIDbh3aqlK4DPsZ1rByC8PFfBThos= golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -214,8 +218,8 @@ golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190508220229-2d0786266e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@ -234,8 +238,8 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.22.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw= gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d/go.mod h1:cuepJuh7vyXfUyUwEgHQXw849cJrilpS5NeIjOWESAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

View file

@ -76,7 +76,7 @@
} }
] ]
}, },
"description": "This is a Pi-hole dashboard when using the https://github.com/eko/pihole-exporter Prometheus exporter with an Influxdb2 Datasource", "description": "This is a PI-Hole dashboard when using the https://github.com/eko/pihole-exporter Prometheus exporter with an Influxdb2 Datasource",
"editable": true, "editable": true,
"fiscalYearStartMonth": 0, "fiscalYearStartMonth": 0,
"gnetId": 17094, "gnetId": 17094,
@ -108,7 +108,7 @@
"refId": "A" "refId": "A"
} }
], ],
"title": "🥧🕳️ Pi-hole", "title": "🍓PI-Hole",
"type": "row" "type": "row"
}, },
{ {
@ -1777,7 +1777,7 @@
] ]
}, },
"timezone": "", "timezone": "",
"title": "Pi-hole Exporter Influxdb 2 (Flux)", "title": "PI-Hole Exporter Influxdb 2 (Flux)",
"uid": "KILVhlozd", "uid": "KILVhlozd",
"version": 1, "version": 1,
"weekStart": "" "weekStart": ""

View file

@ -67,7 +67,7 @@
} }
] ]
}, },
"description": "This is a Pi-hole dashboard when using the https://github.com/eko/pihole-exporter Prometheus exporter", "description": "This is a PI-Hole dashboard when using the https://github.com/eko/pihole-exporter Prometheus exporter",
"editable": true, "editable": true,
"gnetId": 10176, "gnetId": 10176,
"graphTooltip": 0, "graphTooltip": 0,
@ -86,7 +86,7 @@
}, },
"id": 60, "id": 60,
"panels": [], "panels": [],
"title": "🥧🕳️ Pi-hole", "title": "🍓PI-Hole",
"type": "row" "type": "row"
}, },
{ {
@ -1522,7 +1522,7 @@
] ]
}, },
"timezone": "", "timezone": "",
"title": "Pi-hole Exporter", "title": "PI-Hole Exporter",
"uid": "Pi-hole-Exporter", "uid": "PI-Hole-Exporter",
"version": 31 "version": 31
} }

View file

@ -6,7 +6,7 @@ import (
) )
var ( var (
// DomainsBlocked - The number of domains being blocked by Pi-hole. // DomainsBlocked - The number of domains being blocked by PI-Hole.
DomainsBlocked = prometheus.NewGaugeVec( DomainsBlocked = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "domains_being_blocked", Name: "domains_being_blocked",
@ -16,7 +16,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// DNSQueriesToday - The number of DNS requests made over Pi-hole over the current day. // DNSQueriesToday - The number of DNS requests made over PI-Hole over the current day.
DNSQueriesToday = prometheus.NewGaugeVec( DNSQueriesToday = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "dns_queries_today", Name: "dns_queries_today",
@ -26,7 +26,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// AdsBlockedToday - The number of ads blocked by Pi-hole over the current day. // AdsBlockedToday - The number of ads blocked by PI-Hole over the current day.
AdsBlockedToday = prometheus.NewGaugeVec( AdsBlockedToday = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "ads_blocked_today", Name: "ads_blocked_today",
@ -36,7 +36,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// AdsPercentageToday - The percentage of ads blocked by Pi-hole over the current day. // AdsPercentageToday - The percentage of ads blocked by PI-Hole over the current day.
AdsPercentageToday = prometheus.NewGaugeVec( AdsPercentageToday = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "ads_percentage_today", Name: "ads_percentage_today",
@ -46,7 +46,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// UniqueDomains - The number of unique domains seen by Pi-hole. // UniqueDomains - The number of unique domains seen by PI-Hole.
UniqueDomains = prometheus.NewGaugeVec( UniqueDomains = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "unique_domains", Name: "unique_domains",
@ -56,7 +56,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// QueriesForwarded - The number of queries forwarded by Pi-hole. // QueriesForwarded - The number of queries forwarded by PI-Hole.
QueriesForwarded = prometheus.NewGaugeVec( QueriesForwarded = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "queries_forwarded", Name: "queries_forwarded",
@ -66,7 +66,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// QueriesCached - The number of queries cached by Pi-hole. // QueriesCached - The number of queries cached by PI-Hole.
QueriesCached = prometheus.NewGaugeVec( QueriesCached = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "queries_cached", Name: "queries_cached",
@ -76,7 +76,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// ClientsEverSeen - The number of clients ever seen by Pi-hole. // ClientsEverSeen - The number of clients ever seen by PI-Hole.
ClientsEverSeen = prometheus.NewGaugeVec( ClientsEverSeen = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "clients_ever_seen", Name: "clients_ever_seen",
@ -86,7 +86,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// UniqueClients - The number of unique clients seen by Pi-hole. // UniqueClients - The number of unique clients seen by PI-Hole.
UniqueClients = prometheus.NewGaugeVec( UniqueClients = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "unique_clients", Name: "unique_clients",
@ -96,7 +96,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// DNSQueriesAllTypes - The number of DNS queries made for all types by Pi-hole. // DNSQueriesAllTypes - The number of DNS queries made for all types by PI-Hole.
DNSQueriesAllTypes = prometheus.NewGaugeVec( DNSQueriesAllTypes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "dns_queries_all_types", Name: "dns_queries_all_types",
@ -106,7 +106,7 @@ var (
[]string{"hostname"}, []string{"hostname"},
) )
// Reply - The number of replies made for every types by Pi-hole. // Reply - The number of replies made for every types by PI-Hole.
Reply = prometheus.NewGaugeVec( Reply = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "reply", Name: "reply",
@ -116,68 +116,68 @@ var (
[]string{"hostname", "type"}, []string{"hostname", "type"},
) )
// TopQueries - The number of top queries made by Pi-hole by domain. // TopQueries - The number of top queries made by PI-Hole by domain.
TopQueries = prometheus.NewGaugeVec( TopQueries = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "top_queries", Name: "top_queries",
Namespace: "pihole", Namespace: "pihole",
Help: "This represent the number of top queries made by Pi-hole by domain", Help: "This represent the number of top queries made by PI-Hole by domain",
}, },
[]string{"hostname", "domain"}, []string{"hostname", "domain"},
) )
// TopAds - The number of top ads made by Pi-hole by domain. // TopAds - The number of top ads made by PI-Hole by domain.
TopAds = prometheus.NewGaugeVec( TopAds = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "top_ads", Name: "top_ads",
Namespace: "pihole", Namespace: "pihole",
Help: "This represent the number of top ads made by Pi-hole by domain", Help: "This represent the number of top ads made by PI-Hole by domain",
}, },
[]string{"hostname", "domain"}, []string{"hostname", "domain"},
) )
// TopSources - The number of top sources requests made by Pi-hole by source host. // TopSources - The number of top sources requests made by PI-Hole by source host.
TopSources = prometheus.NewGaugeVec( TopSources = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "top_sources", Name: "top_sources",
Namespace: "pihole", Namespace: "pihole",
Help: "This represent the number of top sources requests made by Pi-hole by source host", Help: "This represent the number of top sources requests made by PI-Hole by source host",
}, },
[]string{"hostname", "source"}, []string{"hostname", "source"},
) )
// ForwardDestinations - The number of forward destinations requests made by Pi-hole by destination. // ForwardDestinations - The number of forward destinations requests made by PI-Hole by destination.
ForwardDestinations = prometheus.NewGaugeVec( ForwardDestinations = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "forward_destinations", Name: "forward_destinations",
Namespace: "pihole", Namespace: "pihole",
Help: "This represent the number of forward destinations requests made by Pi-hole by destination", Help: "This represent the number of forward destinations requests made by PI-Hole by destination",
}, },
[]string{"hostname", "destination"}, []string{"hostname", "destination"},
) )
// QueryTypes - The number of queries made by Pi-hole by type. // QueryTypes - The number of queries made by PI-Hole by type.
QueryTypes = prometheus.NewGaugeVec( QueryTypes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "querytypes", Name: "querytypes",
Namespace: "pihole", Namespace: "pihole",
Help: "This represent the number of queries made by Pi-hole by type", Help: "This represent the number of queries made by PI-Hole by type",
}, },
[]string{"hostname", "type"}, []string{"hostname", "type"},
) )
// Status - Is Pi-hole enabled? // Status - Is PI-Hole enabled?
Status = prometheus.NewGaugeVec( Status = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "status", Name: "status",
Namespace: "pihole", Namespace: "pihole",
Help: "This if Pi-hole is enabled", Help: "This if PI-Hole is enabled",
}, },
[]string{"hostname"}, []string{"hostname"},
) )
) )
// Init initializes all Prometheus metrics made available by Pi-hole exporter. // Init initializes all Prometheus metrics made available by PI-Hole exporter.
func Init() { func Init() {
initMetric("domains_blocked", DomainsBlocked) initMetric("domains_blocked", DomainsBlocked)
initMetric("dns_queries_today", DNSQueriesToday) initMetric("dns_queries_today", DNSQueriesToday)

View file

@ -43,7 +43,7 @@ func (c *ClientChannel) String() string {
} }
} }
// Client struct is a Pi-hole client to request an instance of a Pi-hole ad blocker. // Client struct is a PI-Hole client to request an instance of a PI-Hole ad blocker.
type Client struct { type Client struct {
httpClient http.Client httpClient http.Client
interval time.Duration interval time.Duration
@ -51,7 +51,7 @@ type Client struct {
Status chan *ClientChannel Status chan *ClientChannel
} }
// NewClient method initializes a new Pi-hole client. // NewClient method initializes a new PI-Hole client.
func NewClient(config *config.Config, envConfig *config.EnvConfig) *Client { func NewClient(config *config.Config, envConfig *config.EnvConfig) *Client {
err := config.Validate() err := config.Validate()
if err != nil { if err != nil {
@ -135,10 +135,10 @@ func (c *Client) setMetrics(stats *Stats) {
} }
metrics.Status.WithLabelValues(c.config.PIHoleHostname).Set(float64(isEnabled)) metrics.Status.WithLabelValues(c.config.PIHoleHostname).Set(float64(isEnabled))
// Pi-hole returns a subset of stats when Auth is missing or incorrect. // Pi-Hole returns a subset of stats when Auth is missing or incorrect.
// This provides a warning to users that metrics are not complete. // This provides a warning to users that metrics are not complete.
if len(stats.TopQueries) == 0 { if len(stats.TopQueries) == 0 {
log.Warnf("Invalid Authentication - Some metrics may be missing. Please confirm your Pi-hole API token / Password for %s", c.config.PIHoleHostname) log.Warnf("Invalid Authentication - Some metrics may be missing. Please confirm your PI-Hole API token / Password for %s", c.config.PIHoleHostname)
} }
for domain, value := range stats.TopQueries { for domain, value := range stats.TopQueries {
@ -175,7 +175,7 @@ func (c *Client) getPHPSessionID() (sessionID string) {
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
if err != nil { if err != nil {
log.Errorf("An error has occured during login to Pi-hole: %v", err) log.Errorf("An error has occured during login to PI-Hole: %v", err)
} }
for _, cookie := range resp.Cookies() { for _, cookie := range resp.Cookies() {
@ -208,18 +208,18 @@ func (c *Client) getStatistics() (*Stats, error) {
resp, err := c.httpClient.Do(req) resp, err := c.httpClient.Do(req)
if err != nil { if err != nil {
return nil, fmt.Errorf("an error has occured during retrieving Pi-hole statistics: %w", err) return nil, fmt.Errorf("an error has occured during retrieving PI-Hole statistics: %w", err)
} }
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to read Pi-hole statistics HTTP response: %w", err) return nil, fmt.Errorf("unable to read PI-Hole statistics HTTP response: %w", err)
} }
err = json.Unmarshal(body, stats) err = json.Unmarshal(body, stats)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to unmarshal Pi-hole statistics to statistics struct model: %w", err) return nil, fmt.Errorf("unable to unmarshal PI-Hole statistics to statistics struct model: %w", err)
} }
return stats, nil return stats, nil

View file

@ -6,7 +6,7 @@ const (
enabledStatus = "enabled" enabledStatus = "enabled"
) )
// Stats struct is the Pi-hole statistics JSON API corresponding model. // Stats struct is the PI-Hole statistics JSON API corresponding model.
type Stats struct { type Stats struct {
DomainsBeingBlocked int `json:"domains_being_blocked"` DomainsBeingBlocked int `json:"domains_being_blocked"`
DNSQueriesToday int `json:"dns_queries_today"` DNSQueriesToday int `json:"dns_queries_today"`

View file

@ -20,10 +20,10 @@ type Server struct {
// NewServer method initializes a new HTTP server instance and associates // NewServer method initializes a new HTTP server instance and associates
// the different routes that will be used by Prometheus (metrics) or for monitoring (readiness, liveness). // the different routes that will be used by Prometheus (metrics) or for monitoring (readiness, liveness).
func NewServer(addr string, port uint16, clients []*pihole.Client) *Server { func NewServer(port uint16, clients []*pihole.Client) *Server {
mux := http.NewServeMux() mux := http.NewServeMux()
httpServer := &http.Server{ httpServer := &http.Server{
Addr: addr + ":" + strconv.Itoa(int(port)), Addr: ":" + strconv.Itoa(int(port)),
Handler: mux, Handler: mux,
} }

View file

@ -22,7 +22,7 @@ func main() {
clients := buildClients(clientConfigs, envConf) clients := buildClients(clientConfigs, envConf)
s := server.NewServer(envConf.BindAddr, envConf.Port, clients) s := server.NewServer(envConf.Port, clients)
go func() { go func() {
s.ListenAndServe() s.ListenAndServe()
close(serverDead) close(serverDead)