【问题标题】:Blackbox Exporter endpoints with FQDN具有 FQDN 的 Blackbox Exporter 端点
【发布时间】:2022-10-25 15:13:51
【问题描述】:

我想知道自己如何在 Blackbox-Exporter 部分下的 Prometheus UI 中获取带有 FQDN 的端点。假设我想探测 https://www.google.de 但我只得到 http://localhost:9115/probe,这是我的示例配置:

- job_name: blackbox-exporter
  metrics_path: /probe
  static_configs:
    - targets: ["https://www.google.de/"]
      labels:
        module: https_get
  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: localhost:9115

这是 Prometheus UI 中的输出:

enter image description here

有没有办法获得https://www.google.de 而不是http://localhost:9115/probe。我会很感激任何建议。先感谢您。

【问题讨论】:

    标签: prometheus prometheus-blackbox-exporter


    【解决方案1】:

    我认为您可以通过以下 URL 获得所需的内容:

    https://BLACKBOX-SERVER/probe?target=https://www.google.de
    

    【讨论】:

    • 你那是什么意思?那我应该用谷歌找到答案吗?我怎么没有想出这么绝妙的主意?如果您没有什么建设性的补充,请不要浪费我的时间。无论如何,感谢您的回复,即使它没有帮助。
    • 不!!!这可不是说笑。我不是要你在谷歌上搜索或类似的东西(你为什么这么认为?)。我不知道我是否正确理解了您的问题,但我的意思是,如果您将浏览器指向 Blackbox 服务器上的“probe?target=TARGET”路径,您可以获得某个目标的所有 Blackbox 指标。试试看,你会看到的。
    • 你好马塞洛,对不起,如果我弄错了。回到问题。您的建议是正确的,但我想我提出的问题不正确。我想知道的是,如果我可以直接在https://fqdn-prometheus/*/targets?search= 下将端点名称从 localhost 更改为 Target FQDN。例如,如果我使用 node_exporter,我总是将 https://ns-blue.com/9100/metrics 作为端点名称。当我探测google.com 而不是localhost:9115 时,我想在黑盒部分获得类似的输出,例如https://www.google.com。你明白我的意思吗?
    【解决方案2】:

    此问题的解决方案(不要将 http(s)://localhost:9115 视为黑盒)是在 DNS 服务器 (CNAME) 中创建正确的条目

    my-prometheus.com  A       IP: xxx.xxx.xxx.xxx
    my-blackbox.com    CNAME   my-prometheus
    

    并在 apache 中创建另一个指向新创建的 CNAME 的虚拟主机。我们用 Puppet 完成所有这些,所以这里是代码:

    prometheus::server::scrape_configs:
      - job_name: prometheus
        scheme: https
        metrics_path: /prom/metrics
        static_configs:
        - targets:
            - 'my-prometheus.com'
    
     - job_name: blackbox-exporter
       scheme: https
       metrics_path: /blackbox/metrics
       static_configs:
        - tartgets:
            - https://www.google.de/
    
       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: "my-blackbox.com"
    
    profile::apache::vhosts:
      blackbox_exporter:
        servername: "my-blackbox.com"
        docroot: /var/www
        port: 443
        ssl: true
        ssl_cert: /path/to/cert.pem
        ssl_key: /path/to/-key.pem
        ssl_chain: /path/to/chain.pem
        directories:
          - path: /blackbox/
            provider: location
            proxy_pass:
              - url: http://localhost:9115/
            require:
              enforce: any
    

    所以你会在 prometheus UI 中得到https://my-blackbox.com/blackbox/metrics。当我们单击该链接时,我们会获得目标的所有指标。您可以在 URL 中查看:https://my-blackbox.com/metrics?module=https_get_ok&target=https%3A%2F%2Fwww.google.de%2F

    我希望这可以帮助别人。感谢马塞洛的帮助。

    【讨论】:

      猜你喜欢
      • 2018-12-01
      • 2019-11-23
      • 1970-01-01
      • 2021-04-26
      • 1970-01-01
      • 2020-06-11
      • 1970-01-01
      • 2021-08-10
      • 1970-01-01
      相关资源
      最近更新 更多