How I would automate monitoring DNS queries in basic Prometheus
utcc.utoronto.ca
utcc.utoronto.ca
The way to do this in Prometheus is to use the following settings on the blackbox module:
[ preferred_ip_protocol: <string> | default = "ip6" ]
[ ip_protocol_fallback: <boolean> | default = true ]
https://github.com/prometheus/blackbox_exporter/blob/master/...So you need 2 modules, one for each ip version. As for automating setting these up, we deploy our Prometheus server with salt so we can use Jinja templating in all our Prometheus config files. That really cuts down on repeating boiler plate code.
This is also interesting for other reasons; in host downtime situations you can sometime see they will drop one type of traffic and not the other.
If you're interested in that, CoreDNS has a Prometheus exporter that lets you see how many requests you've made through it. You can therefore use CoreDNS as a "proxy" DNS to log all of your DNS queries.
In my case, I modified the CoreDNS code to also include the request in the exported metrics - with this you can see all of your DNS requests (over time) and see if there was something odd.
Doesn't that create an explosion of labels?
On top of that, at least in my case, I don't resolve a huge amount of new FQDNs
It also has a feature which will query internal databases to find expected targets (kinda like service discovery). This covers more specific checks than what the DNS-based targets will provide.
These together mean that essentially no endpoint in our infrastructure is missing from being monitored in some fashion.
The exporter performs SSL checks (lifetime remaining etc) as well as providing HTTP/TCP latency metrics.
TL;DR: Correct answer: install dnsdist infront of your DNS servers.
Then you get stats and query monitoring galore, with DNS fault-tolerant load-balancing to boot.
To be clear, this is the blog of one person at the University of Toronto, representing only himself, who has been working on Unix and Linux systems for, oh, probably 40 years at this point.
"the world" is a bit too wide, using some particular ones like in the example may trigger false alarms if they can't be reached or they have some internal problem. But for widely enough used ones that may be something to be aware of anyway.