Among the Blackbox exporter's probe types is DNS.
As with other probe types, DNS probes are intended to be used to run one query against many different DNS servers by Prometheus, and verify that the DNS servers are working. Let's try it out by checking if DNS servers are returning that robustperception.io is using Google for receiving email:
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.12.0/blackbox_exporter-0.12.0.linux-amd64.tar.gz tar -xzf blackbox_exporter-*.linux-amd64.tar.gz cd blackbox_exporter-* cat > blackbox.yml << EOF modules: dns_rp_mx: prober: dns dns: query_name: "robustperception.io" query_type: "MX" validate_answer_rrs: fail_if_not_matches_regexp: - "robustperception.io.\t.*\tIN\tMX\t.*google.*" EOF ./blackbox_exporter
If you visit http://localhost:9115/probe?module=dns_rp_mx&target=18.104.22.168 this will be tested against Google's Public DNS, and should succeed. In reality you'd usually point this at your own authoritative DNS servers using a sample query rather than verifying that a public DNS service is working - though you could also use it like this to check that records like MX are present. For A and AAAA records you're generally better off using an icmp/tcp/http probe to see if the service as a whole is working, which will implicitly also test DNS. As mentioned in a previous post, you can also add the debug parameter to see the full DNS response: http://localhost:9115/probe?module=dns_rp_mx&target=22.214.171.124&debug=true.
You can then use this in your
prometheus.yml as you would any other Blackbox module:
scrape_configs: - job_name: 'blackbox_dns' metrics_path: /probe params: module: [dns_rp_mx] static_configs: - targets: - 126.96.36.199 # Test various public DNS providers are working. - 188.8.131.52 - 184.108.40.206 - 220.127.116.11 relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 127.0.0.1:9115
Other features of the DNS prober include being able to select TCP or UDP, checking the response code, and checking authoritative and additional resource records that are returned.
Have questions about the Blackbox exporter? Contact us.