On Thursday, 5 March 2020 19:23:51 UTC, Yagyansh S. Kumar wrote:
>
> Found my stupid mistake. It works now. Thanks!
> I have another query though. This maybe just a ridiculous question, but is 
> there any way I can get the hostnames for the targets I configured as ICMP 
> ping targets for Blackbox exporter? I know Blackbox exporter itself does 
> not expose any hostname but still is there something that can be done?
>
>
Not a ridiculous question.  You can do exactly the same with blackbox: you 
need to set the __param_target rather than the __address__ (because you 
will set __address__ to point to blackbox_exporter itself)


  - job_name: blackbox
    file_sd_configs:
      - files:
        - /etc/prometheus/targets.d/blackbox_targets.yml
    metrics_path: /probe
    relabel_configs:
      - source_labels: [__address__]
        regex: '([^/]+)'  # name or address only
        target_label: instance

      - source_labels: [__address__]
        regex: '([^/]+)'  # name or address only
        target_label: __param_target

      - source_labels: [__address__]
        regex: '(.+)/(.+)'  # name/address
        target_label: instance
        replacement: '${1}'

      - source_labels: [__address__]
        regex: '(.+)/(.+)'  # name/address
        target_label: __param_target
        replacement: '${2}'

      - source_labels: [module]
        target_label: __param_module

      - target_label: __address__
        replacement: 127.0.0.1:9115  # Blackbox exporter

Then you create /etc/prometheus/targets.d/blackbox.yml like this:

- labels:
    module: icmp
  targets:
    - foo/1.2.3.4
    - bar/5.6.7.8

- labels:
    module: http_2xx
  targets:
    - baz/9.10.11.12

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/783ffd4c-479b-4a64-a1cc-4268f47468e3%40googlegroups.com.

Reply via email to