nlamirault / pihole_exporter

Prometheus exporter for PiHole metrics
Apache License 2.0
76 stars 20 forks source link

Can't unmarshall response without Top Ads #1

Open nlamirault opened 7 years ago

nlamirault commented 7 years ago
pihole_exporter_1     | time="2016-11-15T17:57:30Z" level=debug msg="Metrics response: {\"domains_being_blocked\":\"101934\",\"dns_queries_today\":\"15\",\"ads_blocked_today\":\"0\",\"ads_percentage_today\":\"0\",\"domains_over_time\":{\"17\":\"15\"},\"ads_over_time\":{\"17\":\"0\"},\"top_queries\":{\"e14.whatsapp.net\":\"2\",\"e9.whatsapp.net\":\"2\",\"e12.whatsapp.net\":\"2\",\"www.google.com\":\"1\",\"mtalk.google.com\":\"1\",\"www.googleapis.com\":\"1\",\"www.google.fr\":\"1\",\"clients3.google.com\":\"1\",\"chat.europnet.org\":\"1\",\"safebrowsing.clients.google.com\":\"1\"},\"top_ads\":[],\"query[AAAA]\":\"6\",\"query[A]\":\"9\",\"8.8.4.4\":\"11\",\"8.8.8.8\":\"5\",\"top_sources\":{\"192.168.1.14\":\"13\",\"192.168.1.18\":\"2\"}}" source="client.go:72" 
pihole_exporter_1     | time="2016-11-15T17:57:30Z" level=error msg="Pihole error: json: cannot unmarshal array into Go value of type map[string]string" source="pihole_exporter.go:143" 
nlamirault commented 7 years ago

Without TopAds it seems to be an array. With TopAds, it seems to be a map :

{"domains_being_blocked":"101934","dns_queries_today":"180","ads_blocked_today":"13","ads_percentage_today":"7.2222222222222","domains_over_time":{"17":"22","18":"158"},"ads_over_time":{"17":"0","18":"13"},"top_queries":{"www.google.com":"9","www.googleapis.com":"5","www.google.fr":"5","api.github.com":"4","apis.google.com":"4","ssl.gstatic.com":"4","e12.whatsapp.net":"4","github.com":"4","clients3.google.com":"3","avatars3.githubusercontent.com":"3"},"top_ads":{"stats.g.doubleclick.net":"2","s.adroll.com":"1","www.googletagmanager.com":"1","munchkin.marketo.net":"1","dx.steelhousemedia.com":"1","cdn.segment.io":"1","collector.githubapp.com":"1","googleads.g.doubleclick.net":"1","static.doubleclick.net":"1","www.googleadservices.com":"1"},"query[AAAA]":"83","query[A]":"97","8.8.4.4":"60","8.8.8.8":"110","top_sources":{"192.168.1.18":"147","192.168.1.14":"33"}}
DL6ER commented 7 years ago

See PR #214.

nlamirault commented 7 years ago

@DL6ER Great !