In our static infrastructure test environment, we can validate the configuration of blackbox_exporter by connecting to the target01 instance as shown here:
cd ./chapter06/
vagrant ssh target01
Then checking the configuration of the provided systemd unit file as shown in the following command:
vagrant@target01:~$ systemctl cat blackbox-exporter
We can see all the required arguments for the blackbox_exporter service in the following snippet from the unit file, including the path to the configuration file:
...
ExecStart=/usr/bin/blackbox_exporter --config.file=/etc/blackbox_exporter/blackbox.yml
...
The configuration we tailored for our example can be found in the following snippet:
modules:
http_2xx:
prober: http
http:
preferred_ip_protocol: ip4
icmp:
prober: icmp
icmp:
preferred_ip_protocol: ip4
On the Prometheus instance, we added the following jobs:
- job_name: 'blackbox-http'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: [ 'http://example.com', 'https://example.com:443' ]
...
- job_name: 'blackbox-icmp'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets:
- prometheus
...
Using the Prometheus web interface, available at http://192.168.42.10:9090/targets, we can validate whether the scrapes are successful (independently of the return status of the probes):
As mentioned before, the /targets page doesn't tell you whether a probe was successful or not. This needs to be validated in the expression browser by querying the probe_success metric:
Some interesting metrics that can be collected from blackbox_exporter (both about the exporter itself and from probes) are:
- blackbox_exporter_config_last_reload_successful, which exposes if the exporter's configuration file was reloaded successfully after a SIGHUP
- probe_http_status_code, which allows you to understand what HTTP status code is being returned when using the HTTP prober module
- probe_ssl_earliest_cert_expiry, which returns the timestamp for when the certificate chain from a SSL probe becomes invalid due to one of the certificates in the chain expiring