prometheusuptimeblack-box-testing

Register multiple blackbox exporters in one job in prometheus


I have my probe job configured on prometheus side like this:

- job_name: 'probe-job'
params:
  module:
  - http_2xx
scrape_interval: 2m
scrape_timeout: 10s
metrics_path: /probe
scheme: http
static_configs:
  - targets: ['xyz/api/serverping']
  - targets: ['xyz/api/serverping']
  - targets: ['xyz/api/serverping']
  - targets: ['xyz/api/serverping']
relabel_configs:
  - source_labels: [__address__]
    target_label: __param_target
  - source_labels: [__param_target]
    target_label: instance
  - target_label: __address__
    replacement: {bb exporter url}:9115

Currently there are 5 servers in different time zones, each running its instance of blackbox exporter. Example above can only address one. The way I would do it now, is to create a new job for every instance, since I can't find a way to insert multiple urls in replacement field. Is there a way to insert multiple blackbox exporter urls, since they will all probe the same targets?


Solution

  • You can use the blackbox exporter as though as it was a normal exporter (rather than how you usually use it).

    scrape_configs:
     - job_name: probe
       params:
         module:
          - http_2xx
         target: 
          - http://xyz/api/serverping
       metrics_path: /probe
       scheme: http
       static_configs:
        - targets:
           - bbexporter1:9115
           - bbexporter2:9115
           - bbexporter3:9115
           - bbexporter4:9115
           - bbexporter5:9115