It's easy to check if HTTP and HTTPS endpoints are working with the Blackbox Exporter.

The Blackbox exporter supports several different types of probes, which includes HTTP. To demonstrate this let's start by downloading and running the blackbox exporter:

tar -xzf blackbox_exporter-*.linux-amd64.tar.gz
cd blackbox_exporter-*

How the Blackbox exporter works is that the /probe endpoint takes module and target URL parameters. Modules are configured in blackbox.yml and the default config includes a http_2xx module which does a HTTP probe which considers any 2xx HTTP response successful. So if you visit :9115/probe?module=http_2xx&target= you will see the result of a probe of In particular look at the probe_success metric, which will be 1 if the probe succeeded and 0 if it failed.


Now that the exporter is working, let's setup a Prometheus to use it:

tar -xzf prometheus-*.tar.gz
cd prometheus-*
cat <<'EOF' > prometheus.yml
 scrape_interval: 10s
 - job_name: blackbox
   metrics_path: /probe
     module: [http_2xx]
    - targets:
    - source_labels: [__address__]
      target_label: __param_target
    - source_labels: [__param_target]
      target_label: instance
    - target_label: __address__
      replacement: # The blackbox exporter.

The relabel_configs change the usual targets into URL parameters on the blackbox exporter. As you can see, paths can be included and HTTP and HTTPS are handled in the same way.

If you wait a few seconds, you will see the result of probe_success in the expression browser. You may see a surprising failure if you don't have a working IPv6 setup, as the Blackbox exporter will prefer an IPv6 address if one is returned by DNS. You can adjust this behaviour by adding preferred_ip_protocol: "ip4" to the module's configuration.


If you wanted to alert on probes failing you should look at both the up and probe_success metrics, to catch either the exporter or target having issues:

- name: example
   - alert: ProbeFailing
     expr: up{job="blackbox"} == 0 or probe_success{job="blackbox"} == 0
     for: 10m


Want to know more about blackbox monitoring? Contact us.