简体   繁体   English

普罗米修斯使用多个目标

[英]Prometheus using multiple target

We need to monitor several of target with prometheus, when we have a short list of targets it was not a problem to modify, however we need to add many targets (50-70 new targets) from diffrent clusters My question if there is a more elegant way to achieve this instead of using it like this我们需要使用 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 
        ...

maybe to mount additional files for each cluster , I mean to provide a file with targets for clusterA only and new file for clusterB only etc, is it possible ?也许为每个集群挂载额外的文件,我的意思是提供一个仅包含 clusterA 目标的文件和仅用于 clusterB 的新文件等,这可能吗?

And the same for jobs, mount each job from a file与作业相同,从文件挂载每个作业

When you have a growing or variable list of targets the best way of managing the job definition is to use SRV records instead of static_configs.当您有一个不断增长的或可变的目标列表时,管理作业定义的最佳方法是使用 SRV 记录而不是 static_configs。

With SRV records you only need to define a dns_sd_config with only one target that will be resolved using a DNS query, then you don't need to change the configuration every time you add a new target only add it on the DNS record使用 SRV 记录,您只需定义一个dns_sd_config其中只有一个将使用 DNS 查询解析的目标,然后您无需在每次添加新目标时更改配置,只需将其添加到 DNS 记录中

An example from the documentation here adapted to your question: 此处文档中的一个示例适用于您的问题:

- 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'

You can use an internal DNS service to generate those records, and if you have targets with http and https mixed you probably need to have two records because the SRV record defines the port to use.您可以使用内部 DNS 服务来生成这些记录,如果您有混合使用httphttps目标,您可能需要有两条记录,因为 SRV 记录定义了要使用的端口。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM