【问题标题】:Prometheus metric relabel for valuePrometheus 度量值重新标记
【发布时间】:2020-10-19 13:37:54
【问题描述】:

基本上我想重新标记度量值,path = /api/v2/users/-/hashes/004fc134-93ba-4c48-b0da-e114f2245b77/activate

/api/v2/users/externalhashes/ops

我在下面尝试过,但它不起作用。 我错过了什么吗?

  metric_relabel_configs:
  - source_labels: [path]
    regex: (\/api\/v2\/users\/+.\/hashes\/[0-9a-z\-]{1,40}\/\w.*)
    replacement: ‘/api/v2/users/externalhashes/ops’
    target_label: path

【问题讨论】:

    标签: monitoring prometheus grafana prometheus-alertmanager


    【解决方案1】:

    尝试以下方法:

    regex: '/api/v2/users/.+/hashes/[0-9a-z\-]{1,40}/\w.*'
    

    【讨论】:

    • 非常感谢马塞洛
    【解决方案2】:

    Prometheus 使用 Golang re2 包解析正则表达式 https://github.com/google/re2/wiki/Syntax

    快速搜索测试人员我发现了这个 https://regoio.herokuapp.com/

    Marcelo 的回答确实有效:+1:

    【讨论】:

    • 感谢您的澄清
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-02
    • 1970-01-01
    • 2021-01-21
    • 1970-01-01
    相关资源
    最近更新 更多