普罗米修斯使用多个目标

时间:2020-09-06 06:42:25

标签: kubernetes prometheus prometheus-operator

当目标列表很短时,我们需要使用普罗米修斯监控几个目标 修改并不是问题,但是我们需要从不同集群中添加许多目标(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的新文件,等等,这有可能吗?

与作业相同,从文件中挂载每个作业

1 个答案:

答案 0 :(得分: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记录定义了要使用的端口。