Previous Lecture Complete and continue  

  DNS Probing

The next probe we shall be exploring is the DNS probe.

Again, we'll be using our previous setup only this time we'll be amending the Blackbox exporter's configuration file to include a module for DNS.

Append the following to your blackbox.yml file:

  dns_test:
    prober: dns
    timeout: 5s
    dns:
      query_name: google.com
      preferred_ip_protocol: ip4

Let's demo the DNS probe by going to:

http://localhost:9115/probe?target=8.8.8.8:53&module=dns_test

This will issue a DNS probe to Google's DNS service!

The response should look like:

As we can see, the probe returned successful with a number of metrics about the probe itself and the response we got.

Open up a second terminal and navigate to the directory containing your Prometheus configuration file (prometheus.yml) and run the following:

cat <<'EOF' > prometheus.yml
global:
  scrape_interval: 10s
scrape_configs:
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [dns_test]
    static_configs:
      - targets:
        - 8.8.8.8:53   # Targets to probe
    relabel_configs:
      # Ensure port is 22, pass as URL parameter
      - source_labels: [__address__]
        regex: (.*)(:.*)?
        replacement: ${1}:22
        target_label: __param_target
      # Make instance label the target
      - source_labels: [__param_target]
        target_label: instance
      # Actually talk to the blackbox exporter though
      - target_label: __address__
        replacement: 127.0.0.1:9115
EOF
./prometheus

This will configure Prometheus to hook it into our running Blackbox exporter and scrape the results of the DNS probe we just ran.