4

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?

Matej
  • 565
  • 2
  • 9
  • 21

1 Answers1

4

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
brian-brazil
  • 31,678
  • 6
  • 93
  • 86
  • This is actually just inverted way of my original question. I have 4 targets to check and here I can address only one (xyz/api...) meaning I should create different jobs for different targets. – Matej Oct 24 '18 at 10:40
  • 2
    I have the same problem as @Matej : I have several nodes, discovered by k8s-node-discovery. I want to check that multiple servers are reachable form this k8s-nodes. From your answer, I would have guessed, that under `target:` I would be able to add multiple entries like `- http://xyz/api/serverping`. However, this is not working. Did I miss something in your answer? – Thomas Böhm Jun 28 '19 at 06:51
  • @brian-brazil Hey, I tried your suggestion again, and it works! Maybe it was old prometheus version before. – Matej Aug 29 '19 at 10:19
  • 1
    Is listing multiple targets under `target:` supported? I'd have a use case for multiple blackbox-exporters _and_ multiple targets to scrape. Putting them all in separate jobs in infeasible for me. – ThreeFx May 04 '20 at 23:22
  • @ThreeFx I have the same use case, and my initial tests show that it's not possible with a list to `target:`. This is what prometheus send as a query param to blackbox. So it seems to be the equivalent of doing `http//blackbox-exporter/probe?module=http_2xx&target=10.0.0.1&target=10.0.0.2`, which doesn't fail, but it doesn't work either since it will only scrape one of the targets. – Pär Berge May 07 '20 at 19:45