π 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:
playbooks/prometheus/deploy_blackbox_exporter.ymlinstalls and runs theblackbox_exporterservice on hosts in theblackbox_exportergroup.playbooks/prometheus/deploy_prometheus_exporters.ymlupdates Prometheus so theblackbox_httpjob appears with the probe targets defined in inventory.
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:
- Use the real URL or IP:port that should answer the probe.
- Use
instanceas the stable, human-friendly service name. - Keep
group: "web"unless you have a clear reason to segment dashboards or queries differently. - Do not add leading or trailing whitespace to
targetvalues. - Prefer one entry per externally meaningful service endpoint.
βοΈ Update an Existing Target
If a service moves or changes ports:
- Find the existing item in
prometheus_setup_blackbox_targets - Update the
target - Keep
instancethe 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:
- the Prometheus Targets page should show job
blackbox_http - you should not expect a separate
blackbox_exportertarget unless the repo adds an explicit scrape job for the exporter process itself
Useful queries:
probe_success{job="blackbox_http"}
probe_duration_seconds{job="blackbox_http"}
Expected behavior:
instanceshould be the friendly name from inventory, such asombi.refol.ustargetshould contain the probed URLprobe_successshould be1for healthy services and0for failing services
In Grafana
Open the Web Service Status dashboard and confirm:
- the service appears by
instancename, not raw URL - status tiles reflect
probe_success - latency panels reflect
probe_duration_seconds
β οΈ Common Mistakes
- Editing the generated Prometheus config instead of inventory
- Deploying
deploy_blackbox_exporter.ymland expecting that alone to createblackbox_httptargets in Prometheus - Forgetting to run
deploy_prometheus_exporters.ymlafter changingprometheus_setup_blackbox_targets - Leaving a stale target in inventory after a service migration
- Changing
instancewhen only the backend URL changed - Introducing whitespace into the
targetvalue - Using an unreachable backend URL while expecting the reverse proxy hostname to be probed
β Summary
To manage blackbox targets:
- Edit
prometheus_setup_blackbox_targetsininventory/prometheus/group_vars/all/main.yml - Deploy
playbooks/prometheus/deploy_blackbox_exporter.ymlif the exporter service is not already installed - Run the Prometheus exporter syntax check
- Deploy
playbooks/prometheus/deploy_prometheus_exporters.yml - Verify the
blackbox_httpjob in Prometheus and Grafana
The inventory list is authoritative, and redeploying applies the exact target set defined there.