在 Prometheus Blackbox 导出器中为每个目标配置唯一名称

Configure unique name per target in Prometheus Blackbox exporter

在带有黑盒导出器的普罗米修斯中,我已经设法配置了 10+ URL 应用程序可用性,所有这些都是通过 URL 识别的,其中一些比下面显示的示例更长所以相反显示 URL 作为实例名称我如何指定每个具有唯一标签。

例如

static_configs:
  - targets:
    - https://www.google.co.in/ # called as GoogleIndia
    - https://www.google.co.uk/ # called as GoogleUK
    - https://www.google.fr/    # called as GoogleFrance

您可以使用 metric_relabel_configs 根据您指定的实例名称构造一个 instance(或全新的)标签,如 this blog post 中所述。

或者您可以像这样指定您的目标,并在此过程中为它们分配任意标签:

static_configs:
  - targets: ['https://www.google.co.in/']
    labels:
      name: `GoogleIndia`
  - targets: ['https://www.google.co.uk/']
    labels:
      name: `GoogleUK`
  - targets: ['https://www.google.fr/']
    labels:
      name: `GoogleFrance`

它更冗长,但也更容易理解和更强大。