Compare commits
No commits in common. "b5811c12701ccfc0f859ab426bd18b3580318dd9" and "ab365886eba2f14c2300626f5e8d5a4526f66f84" have entirely different histories.
b5811c1270
...
ab365886eb
|
@ -223,7 +223,6 @@ scrape_configs:
|
|||
| 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
|
||||
|
|
|
@ -183,7 +183,7 @@ func (c Config) hostnameURL() string {
|
|||
|
||||
// PIHoleStatsURL returns the stats url
|
||||
func (c Config) PIHoleStatsURL() string {
|
||||
return c.hostnameURL() + "/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&overTimeData10mins&jsonForceObject"
|
||||
return c.hostnameURL() + "/admin/api.php?summaryRaw&overTimeData&topItems&recentItems&getQueryTypes&getForwardDestinations&getQuerySources&jsonForceObject"
|
||||
}
|
||||
|
||||
// PIHoleLoginURL returns the login url
|
||||
|
|
6
go.mod
6
go.mod
|
@ -4,11 +4,11 @@ go 1.20
|
|||
|
||||
require (
|
||||
github.com/heetch/confita v0.10.0
|
||||
github.com/prometheus/client_golang v1.19.1
|
||||
github.com/prometheus/client_golang v1.19.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/stretchr/testify v1.9.0
|
||||
github.com/xonvanetta/shutdown v0.0.3
|
||||
golang.org/x/net v0.25.0
|
||||
golang.org/x/net v0.22.0
|
||||
)
|
||||
|
||||
require (
|
||||
|
@ -20,7 +20,7 @@ require (
|
|||
github.com/prometheus/client_model v0.5.0 // indirect
|
||||
github.com/prometheus/common v0.48.0 // indirect
|
||||
github.com/prometheus/procfs v0.12.0 // indirect
|
||||
golang.org/x/sys v0.20.0 // indirect
|
||||
golang.org/x/sys v0.18.0 // indirect
|
||||
google.golang.org/protobuf v1.33.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
12
go.sum
12
go.sum
|
@ -127,8 +127,8 @@ 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.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 v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
|
||||
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
|
||||
github.com/prometheus/client_golang v1.19.0 h1:ygXvpU1AoN1MhdzckN+PyD9QJOSD4x7kmXYlnfbA6JU=
|
||||
github.com/prometheus/client_golang v1.19.0/go.mod h1:ZRM9uEAypZakd+q/x7+gmsvXdURP+DABIEIjnmDdp+k=
|
||||
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-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
|
@ -188,8 +188,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-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.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||
golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc=
|
||||
golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
|
||||
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-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
@ -208,8 +208,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-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.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
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/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -175,16 +175,6 @@ var (
|
|||
},
|
||||
[]string{"hostname"},
|
||||
)
|
||||
|
||||
// QueriesLast10min - Number of queries in the last full slot of 10 minutes
|
||||
QueriesLast10min = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "queries_last_10min",
|
||||
Namespace: "pihole",
|
||||
Help: "Number of queries in the last full slot of 10 minutes",
|
||||
},
|
||||
[]string{"hostname"},
|
||||
)
|
||||
)
|
||||
|
||||
// Init initializes all Prometheus metrics made available by Pi-hole exporter.
|
||||
|
@ -206,7 +196,6 @@ func Init() {
|
|||
initMetric("forward_destinations", ForwardDestinations)
|
||||
initMetric("querytypes", QueryTypes)
|
||||
initMetric("status", Status)
|
||||
initMetric("queries_last_10min", QueriesLast10min)
|
||||
}
|
||||
|
||||
func initMetric(name string, metric *prometheus.GaugeVec) {
|
||||
|
|
|
@ -160,20 +160,6 @@ func (c *Client) setMetrics(stats *Stats) {
|
|||
for queryType, value := range stats.QueryTypes {
|
||||
metrics.QueryTypes.WithLabelValues(c.config.PIHoleHostname, queryType).Set(value)
|
||||
}
|
||||
|
||||
// Pi-hole returns a map of unix epoch time with the number of queries in slots of 10 minutes.
|
||||
// The last epoch is the current in-progress time slot, with queries still being added.
|
||||
// We return the second latest epoch, which is definitive.
|
||||
var lastEpoch, secondLastEpoch int
|
||||
for timestamp := range stats.DomainsOverTime {
|
||||
if timestamp > lastEpoch {
|
||||
secondLastEpoch = lastEpoch
|
||||
lastEpoch = timestamp
|
||||
} else if timestamp > secondLastEpoch && timestamp != lastEpoch {
|
||||
secondLastEpoch = timestamp
|
||||
}
|
||||
}
|
||||
metrics.QueriesLast10min.WithLabelValues(c.config.PIHoleHostname).Set(float64(stats.DomainsOverTime[secondLastEpoch]))
|
||||
}
|
||||
|
||||
func (c *Client) getPHPSessionID() (string, error) {
|
||||
|
|
|
@ -38,7 +38,6 @@ type Stats struct {
|
|||
ForwardDestinations map[string]float64 `json:"forward_destinations"`
|
||||
QueryTypes map[string]float64 `json:"querytypes"`
|
||||
Status string `json:"status"`
|
||||
DomainsOverTime map[int]int `json:"domains_over_time"`
|
||||
}
|
||||
|
||||
// ToString method returns a string of the current statistics struct.
|
||||
|
|
Loading…
Reference in New Issue