Fix go report errors and updated README with new metric

This commit is contained in:
Eldwan Brianne 2020-11-03 23:12:17 +01:00
parent 645a647497
commit 7a328b11be
4 changed files with 9 additions and 7 deletions

View File

@ -129,3 +129,4 @@ scrape_configs:
| adguard_top_blocked_domains | This represent the top blocked domains | | adguard_top_blocked_domains | This represent the top blocked domains |
| adguard_top_clients | This represent the top clients | | adguard_top_clients | This represent the top clients |
| adguard_top_queried_domains | This represent the top domains that are queried | | adguard_top_queried_domains | This represent the top domains that are queried |
| adguard_query_types | This represent the types of DNS queries |

View File

@ -131,8 +131,8 @@ func (c *Client) setLogMetrics(logdata *LogData) {
logstats := logdata.Data[i] logstats := logdata.Data[i]
if logstats.DNS != nil { if logstats.DNS != nil {
for j := range logstats.DNS { for j := range logstats.DNS {
dns_type := logstats.DNS[j].Type dnsType := logstats.DNS[j].Type
m[dns_type] += 1 m[dnsType] += 1
} }
} }
} }

View File

@ -15,26 +15,26 @@ type Stats struct {
TopClients []map[string]int `json:"top_clients"` TopClients []map[string]int `json:"top_clients"`
} }
// DNS answer struct in the log // DNSAnswer struct from LogStats
type DNSAnswer struct { type DNSAnswer struct {
Ttl float64 `json:"ttl"` Ttl float64 `json:"ttl"`
Type string `json:"type"` Type string `json:"type"`
Value string `json:"value"` Value string `json:"value"`
} }
// DNS query struct in the log // DNSQuery struct from LogStats
type DNSQuery struct { type DNSQuery struct {
Class string `json:"class"` Class string `json:"class"`
Host string `json:"host"` Host string `json:"host"`
Type string `json:"type"` 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 { type LogStats struct {
DNS []DNSAnswer `json:"answer"` DNS []DNSAnswer `json:"answer"`
DNSSec bool `json:"answer_dnssec"` DNSSec bool `json:"answer_dnssec"`
Client string `json:"client"` Client string `json:"client"`
Client_proto string `json:"client_proto"` ClientProto string `json:"client_proto"`
Elapsed string `json:"elapsedMs"` Elapsed string `json:"elapsedMs"`
Question DNSQuery `json:"question"` Question DNSQuery `json:"question"`
Reason string `json:"reason"` Reason string `json:"reason"`
@ -43,6 +43,7 @@ type LogStats struct {
Upstream string `json:"upstream"` Upstream string `json:"upstream"`
} }
// LogData struct for the Adguard log statistics JSON API corresponding model.
type LogData struct { type LogData struct {
Data []LogStats `json:"data"` Data []LogStats `json:"data"`
Oldest string `json:"oldest"` Oldest string `json:"oldest"`

View File

@ -97,7 +97,7 @@ var (
[]string{"hostname", "client"}, []string{"hostname", "client"},
) )
// Answer // QueryTypes - The type of DNS Queries (A, AAAA...)
QueryTypes = prometheus.NewGaugeVec( QueryTypes = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
Name: "query_types", Name: "query_types",