Setting the IP for Blackbox_exporter

19 views
Skip to first unread message

Romenyrr

unread,
May 27, 2020, 9:01:50 PM5/27/20
to Prometheus Users
Greetings,

I'm setting up an http probe on an AWS EKS cluster, and I'm curious if there's a better way to set the __address__ label rather than hardcoding a POD IP to the prometheus yaml. As per the instructions found here, I started here as a baseline and that worked fine
- job_name: "blackbox"
    honor_labels: true
    kubernetes_sd_configs:
      - role: pod
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_container_name]
        regex: 'blackbox-exporter'
        action: keep

- job_name: 'blackbox-healthcheck'
    metrics_path: /probe
    params:
      module: 
      - http_2xx
    static_configs:
      - targets:
        - google.com
        - facebook.com
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 10.0.2.43:9115  # The blackbox exporter's real hostname:port.


I attempted to do a dynamic replacement of the IP to point to the pod_ip that hosts the pod, but that didn't work and it was just probing itself :(. Here's what that attempt looked like. Is there a cleaner way to pass in the pod IP from one job to another? Should I be taking a different approach? Any recommendations would be greatly appreciated

- job_name: "blackbox"
    honor_labels
: true
    kubernetes_sd_configs
:
     
- role: pod
    relabel_configs
:
     
- source_labels: [__meta_kubernetes_pod_container_name]
        regex
: 'blackbox-exporter'
        action
: keep
 
- job_name: 'blackbox-healthcheck'
    metrics_path
: /probe
   
params:
     
module:
     
- http_2xx
    kubernetes_sd_configs
:
     
- role: pod
    static_configs
:
     
- targets:
       
- google.com
       
- facebook.com
    relabel_configs
:
     
- source_labels: [__address__]
        target_label
: __param_target
     
- source_labels: [__param_target]
        target_label
: instance
     
- source_labels: [__meta_kubernetes_pod_container_name]
        regex
: 'blackbox-exporter'
        action
: keep
     
- action: replace
        source_labels
: [__meta_kubernetes_pod_ip]
        target_label
: __address__
        replacement
: ${1}:9115









Reply all
Reply to author
Forward
0 new messages