如何从普罗米修斯的标签中删除目标

How drop a target from a label in prometheus

我想我正在尝试做一些很简单的事情,但我不知道该怎么做 :D

所以我使用 backbox exporter 做一些 HTTP 检查,我的主机列表存储在文件中。

我想对目标进行 HTTP 检查是标签 feature=web(因为其他主机不响应 HTTP :D)。

但我不知道该怎么做。

所以我的配置


  - job_name: blackbox_http
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
    - targets: 
    file_sd_configs:
      - files:
        - hosts/*.json

    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: localhost:9115 

还有我的 hosts.json 个文件样本

[
    {
        "targets": [
            "serv1",
            "serv2"
        ],
        "labels": {
            "feature": "web"
        }
    },
    {
        "targets": [
            "serv3"
        ],
        "labels": {
            "feature": "db"
        }
    }
]

我想我需要在 relabel_configs 上做一个 action: drop,但我不知道如何在标签上做。 那你有什么想法吗?

在此先感谢您的帮助

终于找到了

      - source_labels: [feature]
        regex: 'web'
        action: keep