Skip to content

Commit 8214d8c

Browse files
authored
Merge pull request #264 from eko/update-cfg-go1.24
Replaced missing API_TOKEN with PASSWORD and upgrade to Go 1.24.1
2 parents c2e1ce0 + 06a9c8b commit 8214d8c

File tree

8 files changed

+98
-95
lines changed

8 files changed

+98
-95
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ name: Test (master)
33
on:
44
push:
55
branches:
6-
- master
6+
- "*"
77

88
jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
go_version: [ '1.20' ]
13+
go_version: ["1.24.1"]
1414
steps:
15-
- uses: actions/checkout@v3
16-
- uses: actions/setup-go@v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
1717
with:
1818
go-version: ${{ matrix.go_version }}
1919

@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
needs: test
2929
steps:
30-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3131
- uses: azure/docker-login@v1
3232
with:
3333
username: ${{ secrets.DOCKER_USERNAME }}

.github/workflows/tag.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ name: Build/Push (tag)
33
on:
44
push:
55
tags:
6-
- '*'
6+
- "*"
77

88
jobs:
99
test:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
go_version: [ '1.20' ]
13+
go_version: ["1.24.1"]
1414
steps:
15-
- uses: actions/checkout@v3
16-
- uses: actions/setup-go@v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v5
1717
with:
1818
go-version: ${{ matrix.go_version }}
1919
- run: go get -t -v ./...
@@ -23,34 +23,34 @@ jobs:
2323
runs-on: ubuntu-latest
2424
needs: test
2525
steps:
26-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2727

28-
- uses: azure/docker-login@v1
29-
with:
30-
username: ${{ secrets.DOCKER_USERNAME }}
31-
password: ${{ secrets.DOCKER_PASSWORD }}
28+
- uses: azure/docker-login@v1
29+
with:
30+
username: ${{ secrets.DOCKER_USERNAME }}
31+
password: ${{ secrets.DOCKER_PASSWORD }}
3232

33-
- name: Set up docker buildx
34-
id: buildx
35-
uses: crazy-max/ghaction-docker-buildx@v1
36-
with:
37-
buildx-version: latest
38-
qemu-version: latest
33+
- name: Set up docker buildx
34+
id: buildx
35+
uses: crazy-max/ghaction-docker-buildx@v1
36+
with:
37+
buildx-version: latest
38+
qemu-version: latest
3939

40-
- name: Docker buildx available platforms
41-
run: echo ${{ steps.buildx.outputs.platforms }}
40+
- name: Docker buildx available platforms
41+
run: echo ${{ steps.buildx.outputs.platforms }}
4242

43-
- name: Get the version
44-
id: get_version
45-
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
43+
- name: Get the version
44+
id: get_version
45+
run: echo ::set-output name=TAG_NAME::${GITHUB_REF/refs\/tags\//}
4646

47-
- name: Run docker buildx build
48-
run: |
49-
docker buildx build \
50-
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
51-
--output=type=registry,push=true \
52-
--tag ekofr/pihole-exporter:${{ steps.get_version.outputs.TAG_NAME }} \
53-
.
47+
- name: Run docker buildx build
48+
run: |
49+
docker buildx build \
50+
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64 \
51+
--output=type=registry,push=true \
52+
--tag ekofr/pihole-exporter:${{ steps.get_version.outputs.TAG_NAME }} \
53+
.
5454
5555
release:
5656
runs-on: ubuntu-latest
@@ -92,25 +92,25 @@ jobs:
9292
- os: ubuntu-latest
9393
goos: windows
9494
goarch: 386
95-
extension: '.exe'
95+
extension: ".exe"
9696
- os: ubuntu-latest
9797
goos: windows
9898
goarch: amd64
99-
extension: '.exe'
99+
extension: ".exe"
100100
runs-on: ${{ matrix.os }}
101101
steps:
102-
- uses: actions/checkout@v3
103-
- uses: actions/setup-go@v3
102+
- uses: actions/checkout@v4
103+
- uses: actions/setup-go@v5
104104
with:
105-
go-version: '1.20'
105+
go-version: "1.24.1"
106106

107107
- name: Download go dependencies
108108
run: go get -t -v ./...
109109

110110
# Release File
111111
- name: Create release
112112
run: GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags "-s -w" -o pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} ./
113-
113+
114114
- name: Upload release assets
115115
id: upload-release-asset
116116
uses: actions/upload-release-asset@v1
@@ -121,11 +121,11 @@ jobs:
121121
asset_path: ./pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
122122
asset_name: pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}
123123
asset_content_type: application/octet-stream
124-
124+
125125
# SHA256 Sum File
126126
- name: Create SHA256 sum
127127
run: sha256sum pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }} > pihole_exporter-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.extension }}.sha256.txt
128-
128+
129129
- name: Upload release assets
130130
id: upload-release-sum-asset
131131
uses: actions/upload-release-asset@v1

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ ARG IMAGE=scratch
22
ARG OS=linux
33
ARG ARCH=amd64
44

5-
FROM golang:1.21.5-alpine3.17 as builder
5+
FROM golang:1.24.1-alpine3.21 as builder
66

77
WORKDIR /go/src/github.com/eko/pihole-exporter
88
COPY . .
99

1010
RUN apk --no-cache add git alpine-sdk
1111

12-
RUN GO111MODULE=on go mod vendor
12+
RUN go mod vendor
1313
RUN CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH go build -ldflags '-s -w' -o binary ./
1414

1515
FROM $IMAGE

README.md

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Pi-hole Prometheus Exporter
22

3-
![Build/Push (master)](https://github.com/eko/pihole-exporter/workflows/Build/Push%20(master)/badge.svg)
3+
![Build/Push (master)](<https://github.com/eko/pihole-exporter/workflows/Build/Push%20(master)/badge.svg>)
44
[![GoDoc](https://godoc.org/github.com/eko/pihole-exporter?status.png)](https://godoc.org/github.com/eko/pihole-exporter)
55
[![GoReportCard](https://goreportcard.com/badge/github.com/eko/pihole-exporter)](https://goreportcard.com/report/github.com/eko/pihole-exporter)
66

@@ -10,32 +10,32 @@ This is a Prometheus exporter for [Pi-hole](https://pi-hole.net/)'s Raspberry PI
1010

1111
Available Grafana Dasboards:
1212

13-
* Prometheus: [Grafana Labs](https://grafana.com/grafana/dashboards/10176-pi-hole-exporter/) / [JSON/Github](https://raw.githubusercontent.com/eko/pihole-exporter/master/grafana/dashboard.json) --> [Preview](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard.jpg)
14-
* InfluxDB 2 (Flux): [Grafana Labs](https://grafana.com/grafana/dashboards/17094-pi-hole-exporter-influxdb-2/) / [JSON/Github](https://raw.githubusercontent.com/eko/pihole-exporter/master/grafana/dashboard-influxdb2.json) --> [Preview](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard-influxdb2.png)
13+
- Prometheus: [Grafana Labs](https://grafana.com/grafana/dashboards/10176-pi-hole-exporter/) / [JSON/Github](https://raw.githubusercontent.com/eko/pihole-exporter/master/grafana/dashboard.json) --> [Preview](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard.jpg)
14+
- InfluxDB 2 (Flux): [Grafana Labs](https://grafana.com/grafana/dashboards/17094-pi-hole-exporter-influxdb-2/) / [JSON/Github](https://raw.githubusercontent.com/eko/pihole-exporter/master/grafana/dashboard-influxdb2.json) --> [Preview](https://raw.githubusercontent.com/eko/pihole-exporter/master/dashboard-influxdb2.png)
1515

1616
## Prerequisites
1717

18-
* [Go](https://golang.org/doc/)
18+
- [Go](https://golang.org/doc/)
1919

2020
## Installation
2121

2222
### Download binary
2323

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

26-
* Architecture **i386** [
27-
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-386) /
28-
[Windows](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-windows-386.exe)
29-
]
30-
* Architecture **amd64** [
31-
[Darwin](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-darwin-amd64) /
32-
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-amd64) /
33-
[Windows](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-windows-amd64.exe)
34-
]
35-
* Architecture **arm** [
36-
[Darwin](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-darwin-arm64) /
37-
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-arm)
38-
]
26+
- Architecture **i386** [
27+
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-386) /
28+
[Windows](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-windows-386.exe)
29+
]
30+
- Architecture **amd64** [
31+
[Darwin](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-darwin-amd64) /
32+
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-amd64) /
33+
[Windows](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-windows-amd64.exe)
34+
]
35+
- Architecture **arm** [
36+
[Darwin](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-darwin-arm64) /
37+
[Linux](https://github.com/eko/pihole-exporter/releases/latest/download/pihole_exporter-linux-arm)
38+
]
3939

4040
### Using Docker
4141

@@ -57,7 +57,7 @@ Or use PiHole's `WEBPASSWORD` as an API token instead of the password
5757
$ API_TOKEN=$(awk -F= -v key="WEBPASSWORD" '$1==key {print $2}' /etc/pihole/setupVars.conf)
5858
$ docker run \
5959
-e 'PIHOLE_HOSTNAME=192.168.1.2' \
60-
-e "PIHOLE_API_TOKEN=$API_TOKEN" \
60+
-e "PIHOLE_PASSWORD=$API_TOKEN" \
6161
-e 'PORT=9617' \
6262
-p 9617:9617 \
6363
ekofr/pihole-exporter:latest
@@ -84,7 +84,7 @@ To do so, you can specify a list of hostnames, protocols, passwords/API tokens a
8484
$ docker run \
8585
-e 'PIHOLE_PROTOCOL=http,http,http" \
8686
-e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
87-
-e "PIHOLE_API_TOKEN=$API_TOKEN1,$API_TOKEN2,$API_TOKEN3" \
87+
-e "PIHOLE_PASSWORD=$API_TOKEN1,$API_TOKEN2,$API_TOKEN3" \
8888
-e "PIHOLE_PORT=8080,8081,8080" \
8989
-e 'PORT=9617' \
9090
-p 9617:9617 \
@@ -97,7 +97,7 @@ If port, protocol and API token/password is the same for all instances, you can
9797
$ docker run \
9898
-e 'PIHOLE_PROTOCOL=http" \
9999
-e 'PIHOLE_HOSTNAME=192.168.1.2,192.168.1.3,192.168.1.4"' \
100-
-e "PIHOLE_API_TOKEN=$API_TOKEN" \
100+
-e "PIHOLE_PASSWORD=$API_TOKEN" \
101101
-e "PIHOLE_PORT=8080" \
102102
-e 'PORT=9617' \
103103
-p 9617:9617 \
@@ -107,6 +107,7 @@ $ docker run \
107107
### From sources
108108

109109
Optionally, you can download and build it from the sources. You have to retrieve the project sources by using one of the following way:
110+
110111
```bash
111112
$ go install github.com/eko/pihole-exporter@latest
112113
# or
@@ -116,10 +117,11 @@ $ git clone https://github.com/eko/pihole-exporter.git
116117
Install the needed vendors:
117118

118119
```
119-
$ GO111MODULE=on go mod vendor
120+
$ go mod vendor
120121
```
121122

122123
Then, build the binary (here, an example to run on Raspberry PI ARM architecture):
124+
123125
```bash
124126
$ GOOS=linux GOARCH=arm GOARM=7 go build -o pihole_exporter .
125127
```
@@ -138,7 +140,7 @@ Or use PiHole's `WEBPASSWORD` as an API token instead of the password
138140

139141
```bash
140142
$ API_TOKEN=$(awk -F= -v key="WEBPASSWORD" '$1==key {print $2}' /etc/pihole/setupVars.conf)
141-
$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_api_token $API_TOKEN
143+
$ ./pihole_exporter -pihole_hostname 192.168.1.10 -pihole_password $API_TOKEN
142144
```
143145

144146
```bash
@@ -178,12 +180,13 @@ Once the exporter is running, you also have to update your `prometheus.yml` conf
178180

179181
```yaml
180182
scrape_configs:
181-
- job_name: 'pihole'
182-
static_configs:
183-
- targets: ['localhost:9617']
183+
- job_name: "pihole"
184+
static_configs:
185+
- targets: ["localhost:9617"]
184186
```
185187
186188
## Available CLI options
189+
187190
```bash
188191
# Hostname of the host(s) where Pi-hole is installed
189192
-pihole_hostname string (optional) (default "127.0.0.1")
@@ -195,42 +198,41 @@ scrape_configs:
195198
-timeout duration (optional) (default 5s)
196199

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

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

203206
# URL Context (first segments of URL path) to the PI-hole admin application
204207
-pihole_admin_context string (optional) (default "admin")
205-
208+
206209
# Port to be used for the exporter
207210
-port string (optional) (default "9617")
208211
```
209212

210213
## Available Prometheus metrics
211214

212-
| Metric name | Description |
213-
|:----------------------------:|-------------------------------------------------------------------------------------------|
215+
| Metric name | Description |
216+
| :--------------------------: | ----------------------------------------------------------------------------------------- |
214217
| pihole_domains_being_blocked | This represent the number of domains being blocked |
215-
| pihole_dns_queries_today | This represent the number of DNS queries made over the current day |
216-
| pihole_ads_blocked_today | This represent the number of ads blocked over the current day |
218+
| pihole_dns_queries_today | This represent the number of DNS queries made over the current day |
219+
| pihole_ads_blocked_today | This represent the number of ads blocked over the current day |
217220
| pihole_ads_percentage_today | This represent the percentage of ads blocked over the current day |
218-
| pihole_unique_domains | This represent the number of unique domains seen |
219-
| pihole_queries_forwarded | This represent the number of queries forwarded |
220-
| pihole_queries_cached | This represent the number of queries cached |
221-
| pihole_clients_ever_seen | This represent the number of clients ever seen |
222-
| pihole_unique_clients | This represent the number of unique clients seen |
221+
| pihole_unique_domains | This represent the number of unique domains seen |
222+
| pihole_queries_forwarded | This represent the number of queries forwarded |
223+
| pihole_queries_cached | This represent the number of queries cached |
224+
| pihole_clients_ever_seen | This represent the number of clients ever seen |
225+
| pihole_unique_clients | This represent the number of unique clients seen |
223226
| pihole_dns_queries_all_types | This represent the number of DNS queries made for all types |
224-
| pihole_reply | This represent the number of replies made for all types |
225-
| pihole_top_queries | This represent the number of top queries made by Pi-hole by domain |
226-
| pihole_top_ads | This represent the number of top ads made by Pi-hole by domain |
227-
| pihole_top_sources | This represent the number of top sources requests made by Pi-hole by source host |
227+
| pihole_reply | This represent the number of replies made for all types |
228+
| pihole_top_queries | This represent the number of top queries made by Pi-hole by domain |
229+
| pihole_top_ads | This represent the number of top ads made by Pi-hole by domain |
230+
| pihole_top_sources | This represent the number of top sources requests made by Pi-hole by source host |
228231
| pihole_forward_destinations | This represent the number of forward destinations requests made by Pi-hole by destination |
229-
| pihole_querytypes | This represent the number of queries made by Pi-hole by type |
230-
| pihole_status | This represent if Pi-hole is enabled |
231-
| queries_last_10min | This represent the number of queries in the last full slot of 10 minutes |
232-
| ads_last_10min | This represent the number of ads in the last full slot of 10 minutes |
233-
232+
| pihole_querytypes | This represent the number of queries made by Pi-hole by type |
233+
| pihole_status | This represent if Pi-hole is enabled |
234+
| queries_last_10min | This represent the number of queries in the last full slot of 10 minutes |
235+
| ads_last_10min | This represent the number of ads in the last full slot of 10 minutes |
234236

235237
## Pihole-Exporter Helm Chart
236238

config/configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (c *Config) String() string {
8181
for i := 0; i < fields.NumField(); i++ {
8282
valueField := fields.Field(i)
8383
typeField := fields.Type().Field(i)
84-
if typeField.Name != "PIHolePassword" && typeField.Name != "PIHoleApiToken" {
84+
if typeField.Name != "PIHolePassword" {
8585
buffer[i] = fmt.Sprintf("%s=%v", typeField.Name, valueField.Interface())
8686
} else if valueField.Len() > 0 {
8787
buffer[i] = fmt.Sprintf("%s=%s", typeField.Name, "*****")
@@ -175,7 +175,7 @@ func (c EnvConfig) show() {
175175
typeField := val.Type().Field(i)
176176

177177
// Do not print password or api token but do print the authentication method
178-
if typeField.Name != "PIHolePassword" && typeField.Name != "PIHoleApiToken" {
178+
if typeField.Name != "PIHolePassword" {
179179
log.Info(fmt.Sprintf("%s : %v", typeField.Name, valueField.Interface()))
180180
} else {
181181
showAuthenticationMethod(typeField.Name, valueField.Len())

0 commit comments

Comments
 (0)