Reputation: 2607
What is the semantics of a job
for a Prometheus blackbox exporter that cites more than one module under params.module
?
I guess it means that all modules are tried and the probe only succeeds if all of them succeed. All the examples I have come across employ only single modules (typically module: [http_2xx]
), and I have not configured an example nor looked it up in the source code so far. Maybe someone here knows already/definitely from direct experience.
Upvotes: 5
Views: 3069
Reputation: 43
You can configure multiple Blackbox Exporter modules in one job:
Forget defining the single module
param for the job
(although there would be a default http_2xx anyway).
Instead, add a __param_module
label to each of the different static_config
lists.
Example from the forum post
static_configs:
- targets: [ url1, url2, url3 ]
labels: { __param_module: http_2xx }
- targets: [ 8.8.8.8, 8.8.4.4 ]
labels: { __param_module: icmp }
Another improvement could be to use the label module
instead of __param_module
.
This way the module
appears as a label in the Prometheus metrics.
Of course, in this case you have to extend the
usual
relabel_configs
with a new item:
relabel_configs:
- source_labels: [__address__]
target_label: instance
- source_labels: [__address__]
target_label: __param_target
- source_labels: [module]
target_label: __param_module
- target_label: __address__
replacement: localhost:9115
Upvotes: 0
Reputation: 10084
Based on the blackbox_exporter
source code it would seem that every probe only ever executes a single test / module. Either you provide the module name in the request (as suggested by the documentation) or else it defaults to http_2xx
.
The only way you could execute multiple modules would appear to be to define a separate Prometheus job, with a different module
parameter value.
The only reason Prometheus' params
is an array rather than a single value is that it's not limited to blackbox_exporter
, it's a general way of sending HTTP parameters to a target (e.g. one might use something like /metrics?module=foo&module=bar
to instruct the target to only return metrics for modules foo
and bar
).
I just tested from the browser and what happens if you query blackbox_exporter
with multiple module
parameter values, is that blackbox_exporter
will ignore everything but the first value.
Upvotes: 6