Setting up a fallback module in Blackbox.

26 views
Skip to first unread message

yagyans...@gmail.com

unread,
Oct 22, 2020, 1:52:45 PM10/22/20
to Prometheus Users
Hi. I want to use a single job and a file for probing targets with different modules. My job currently looks like this.

  - job_name: 'blackbox_TestingAllInSameFile'
    metrics_path: /probe
    file_sd_configs:
      - files:
        - /root/test.yml
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - source_labels: [module]
        target_label: __param_module
      - target_label: __address__
        replacement: 172.20.10.99:9115
    scrape_interval: 10s

My target file looks like this:

- targets:
     - t1
     - t2
  labels:
     module: 'http_healthcheck'
     checkname: 'a'
     cluster: 'b'
     node: 'c'
     env: 'PROD'

My http_healthcheck module will be used for most of the targets. So, is there any way to make it as a fallback module and not define module label everytime for this particular module? I mean I want to define the module label only when it is anything other than http_healthcheck.
Is there any way we could achieve this using relabel_configs?

Thanks in advance!

Julien Pivotto

unread,
Oct 22, 2020, 4:08:18 PM10/22/20
to yagyans...@gmail.com, Prometheus Users
Yes, you could do:

- source_labels: [__param_module]
regex: '()'
replacement: 'http_healthcheck'
target_label: __param_module

>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/990ec69c-5214-455c-ab10-c64a6a59ba46n%40googlegroups.com.


--
Julien Pivotto
@roidelapluie

yagyans...@gmail.com

unread,
Oct 23, 2020, 2:01:12 AM10/23/20
to Prometheus Users
Thanks, Julien.

yagyans...@gmail.com

unread,
Dec 8, 2020, 12:24:09 PM12/8/20
to Prometheus Users
Hi Julien,

One query.

Using this regex combination that you mentioned, the module is getting set to http_healthcheck itself for all the targets even if I specify a different module for some of the targets.
Reply all
Reply to author
Forward
0 new messages