【问题标题】:Prometheus using multiple targetPrometheus 使用多个目标
【发布时间】:2020-09-06 06:42:25
【问题描述】:

当我们有一个简短的目标列表时,我们需要使用 prometheus 监控几个目标 修改不是问题,但是我们需要从不同的集群中添加许多目标(50-70 个新目标) 我的问题是否有更优雅的方式来实现这一点 而不是像这样使用它

- job_name: blackbox-http # To get metrics about the exporter’s targets
  metrics_path: /probe
  params:
    module: [http_2xx]
  static_configs:
    - targets:
      - http://clusterA   
      - https://clusterA   
      - http://clusterB 
      - http://clusterC 
      - http://clusterC 
        ...

也许要为每个集群挂载额外的文件,我的意思是提供一个文件,其中只有 clusterA 的目标和 clusterB 的新文件等,有可能吗?

对于作业也是如此,从文件中挂载每个作业

【问题讨论】:

    标签: kubernetes prometheus prometheus-operator


    【解决方案1】:

    当您的目标列表不断增长或可变时,管理作业定义的最佳方法是使用 SRV 记录而不是 static_configs。

    使用 SRV 记录,您只需定义一个 dns_sd_config,其中只有一个将使用 DNS 查询解析的目标,然后您无需在每次添加新目标时更改配置,只需将其添加到DNS记录

    文档here 中的一个示例适用于您的问题:

    - job_name: 'myjob'
      metrics_path: /probe
      params:
        module: [http_2xx]
      dns_sd_configs:
      - names:
        - 'telemetry.http.srv.example.org'
        - 'telemetry.https.api.srv.example.org'
    

    您可以使用内部 DNS 服务来生成这些记录,如果您的目标包含 httphttps 混合,您可能需要有两条记录,因为 SRV 记录定义了要使用的端口。

    【讨论】:

      猜你喜欢
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 2016-08-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-29
      • 1970-01-01
      相关资源
      最近更新 更多