🌐 Adding Blackbox Exporter Targets

πŸ“– Purpose

This runbook explains how to add, update, or remove web probe targets for the Prometheus Blackbox Exporter in this repository.

The single source of truth for blackbox targets is:

inventory/prometheus/group_vars/all/main.yml

Do not edit rendered Prometheus configuration on the host. Do not rely on previously deployed scrape targets remaining in place. The inventory list is authoritative.


🧭 How Blackbox Targets Work Here

Blackbox targets are defined in prometheus_setup_blackbox_targets and are rendered into the Prometheus scrape configuration by the prometheus_setup role.

The exporter service host and the probe target list are separate concerns:

If the exporter service is running but blackbox_http is missing from Prometheus, Prometheus most likely has not been refreshed with the current inventory target list yet.

Each target supports:

Field Required Purpose
target Yes The URL Prometheus should probe through Blackbox Exporter
instance Yes The friendly service name shown in Grafana
group No A logical grouping label; defaults to the configured blackbox group label

Example:

prometheus_setup_blackbox_targets:
  - target: "http://192.168.20.155:3579"
    instance: "ombi.refol.us"
    group: "web"

πŸ›  Add a New Target

1. Edit the Prometheus inventory group vars

Open:

inventory/prometheus/group_vars/all/main.yml

Add a new item under prometheus_setup_blackbox_targets:

  - target: "http://192.168.20.200:8080"
    instance: "example.refol.us"
    group: "web"

Guidelines:


✏️ Update an Existing Target

If a service moves or changes ports:

  1. Find the existing item in prometheus_setup_blackbox_targets
  2. Update the target
  3. Keep instance the same if the service identity has not changed

Example:

  - target: "http://192.168.20.210:8080"
    instance: "example.refol.us"
    group: "web"

This preserves Grafana naming and keeps dashboards readable even when the backend address changes.


πŸ—‘ Remove a Target

To stop probing a service, delete its item from prometheus_setup_blackbox_targets.

Because inventory is the only source of truth, removing the entry and redeploying Prometheus exporters removes that target from the generated Prometheus configuration.


βœ… Validate the Change

If Ansible is installed in the repo Python environment:

source /opt/python_3.12/bin/activate
ansible-playbook -i inventory/prometheus/inventory.ini playbooks/prometheus/deploy_prometheus_exporters.yml --syntax-check

This confirms the playbook and the rendered Prometheus configuration path still parse correctly.


πŸš€ Deploy the Updated Target List

If the Blackbox Exporter service has not been deployed yet, install it first:

ansible-playbook -i inventory/prometheus/inventory.ini playbooks/prometheus/deploy_blackbox_exporter.yml

This installs the exporter process itself. It does not make probe targets appear in Prometheus by itself.

After that, refresh the Prometheus scrape configuration.

Run:

ansible-playbook -i inventory/prometheus/inventory.ini playbooks/prometheus/deploy_prometheus_exporters.yml

If you normally use a shell variable for the inventory, use your existing repo workflow instead.

This updates the Prometheus configuration so the new blackbox target list is applied.


πŸ” Verify After Deployment

In Prometheus

Check the blackbox job in the Prometheus UI and confirm the new target appears.

Important:

Useful queries:

probe_success{job="blackbox_http"}
probe_duration_seconds{job="blackbox_http"}

Expected behavior:

In Grafana

Open the Web Service Status dashboard and confirm:


⚠️ Common Mistakes


βœ… Summary

To manage blackbox targets:

  1. Edit prometheus_setup_blackbox_targets in inventory/prometheus/group_vars/all/main.yml
  2. Deploy playbooks/prometheus/deploy_blackbox_exporter.yml if the exporter service is not already installed
  3. Run the Prometheus exporter syntax check
  4. Deploy playbooks/prometheus/deploy_prometheus_exporters.yml
  5. Verify the blackbox_http job in Prometheus and Grafana

The inventory list is authoritative, and redeploying applies the exact target set defined there.