diff --git a/README.md b/README.md index 0ba4712..2ae42ad 100644 --- a/README.md +++ b/README.md @@ -129,3 +129,4 @@ scrape_configs: | adguard_top_blocked_domains | This represent the top blocked domains | | adguard_top_clients | This represent the top clients | | adguard_top_queried_domains | This represent the top domains that are queried | +| adguard_query_types | This represent the types of DNS queries | diff --git a/internal/adguard/client.go b/internal/adguard/client.go index d97cb9b..587976d 100644 --- a/internal/adguard/client.go +++ b/internal/adguard/client.go @@ -131,8 +131,8 @@ func (c *Client) setLogMetrics(logdata *LogData) { logstats := logdata.Data[i] if logstats.DNS != nil { for j := range logstats.DNS { - dns_type := logstats.DNS[j].Type - m[dns_type] += 1 + dnsType := logstats.DNS[j].Type + m[dnsType] += 1 } } } diff --git a/internal/adguard/model.go b/internal/adguard/model.go index 7416125..97c34dc 100644 --- a/internal/adguard/model.go +++ b/internal/adguard/model.go @@ -15,26 +15,26 @@ type Stats struct { TopClients []map[string]int `json:"top_clients"` } -// DNS answer struct in the log +// DNSAnswer struct from LogStats type DNSAnswer struct { Ttl float64 `json:"ttl"` Type string `json:"type"` Value string `json:"value"` } -// DNS query struct in the log +// DNSQuery struct from LogStats type DNSQuery struct { Class string `json:"class"` Host string `json:"host"` Type string `json:"type"` } -// LogStats struct for the Adguard log statistics JSON API corresponding model. +// LogStats struct, sub struct of LogData to collect the dns stats from the log type LogStats struct { DNS []DNSAnswer `json:"answer"` DNSSec bool `json:"answer_dnssec"` Client string `json:"client"` - Client_proto string `json:"client_proto"` + ClientProto string `json:"client_proto"` Elapsed string `json:"elapsedMs"` Question DNSQuery `json:"question"` Reason string `json:"reason"` @@ -43,6 +43,7 @@ type LogStats struct { Upstream string `json:"upstream"` } +// LogData struct for the Adguard log statistics JSON API corresponding model. type LogData struct { Data []LogStats `json:"data"` Oldest string `json:"oldest"` diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 1211238..1cbed02 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -97,7 +97,7 @@ var ( []string{"hostname", "client"}, ) - // Answer + // QueryTypes - The type of DNS Queries (A, AAAA...) QueryTypes = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "query_types",