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 is using Google for receiving email:

tar -xzf blackbox_exporter-*.linux-amd64.tar.gz
cd blackbox_exporter-*
cat > blackbox.yml << EOF
    prober: dns
      query_name: ""
      query_type: "MX"
         - "\t.*\tIN\tMX\t.*google.*"

If you visit http://localhost:9115/probe?module=dns_rp_mx&target= 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=

You can then use this in your prometheus.yml as you would any other Blackbox module:

  - job_name: 'blackbox_dns'
    metrics_path: /probe
      module: [dns_rp_mx]
      - targets:
        -  # Test various public DNS providers are working.
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__

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.