【问题标题】:How to replace a label in a prometheus re-label step?如何在普罗米修斯重新标记步骤中替换标签?
【发布时间】:2016-12-19 23:02:34
【问题描述】:

我正在使用基于 prometheus 文件的服务发现。但是,当拉入我的服务器列表时,我意识到我的服务的指标端点是 /prometheus 没有 /metrics

我发现我可以使用重新标记来解决此问题。

- job_name: 'servers-dev'
  file_sd_configs:
  - files: ['/prometheus/topology.json']

  relabel_configs:
  - source_labels: [?????]
    action: replace
    target_label: __metrics_path__  #I want this to be /prometheus
    regex: (.+)

如何使用重新标记添加标签?

【问题讨论】:

    标签: prometheus


    【解决方案1】:

    这里不需要重新标记,你可以添加

      metrics_path: /prometheus
    

    到抓取配置。

    要通过重新标记来做到这一点,你会这样做:

      - target_label: __metrics_path__
        replacement: /prometheus
    

    因为默认设置是您无需担心其他配置选项。

    【讨论】:

    • :facepalm: 感谢metrics_path 的提醒,我一直在浏览 Kubernetes SD,以至于我的眼睛已经越过了。还要感谢重新标记示例,因为我实际上需要添加一个额外的标签并且效果很好。
    猜你喜欢
    • 1970-01-01
    • 2022-12-02
    • 1970-01-01
    • 2021-11-25
    • 1970-01-01
    • 2022-12-22
    • 2020-01-10
    • 2020-11-12
    • 2021-07-20
    相关资源
    最近更新 更多