【问题标题】:PromQL/prometheus query label_replace() multiplePromQL/prometheus 查询 label_replace() 多个
【发布时间】:2021-10-25 07:30:14
【问题描述】:

试图找到一种使用 Prometheus 查询来替换 2 个或更多标签的方法,但没有找到任何好的和“短”的方法。

这是我所拥有的:

label_replace(
label_replace(
label_replace(
  label_replace(
    rate(spring_integration_send_seconds_count{result!="success", application="MyApplicationName"}[1m])
    ,"service", "$1", "name", "(.*).ConsumerEndpointFactoryBean.*"
    )
      , "service", "$1", "name", "(.*).channel.*"
      )
        , "service", "$1", "name", "(.*).Channel.*"
      )
       , "service", "$1", "name", "(.*).handler.*"
      )
)

是否有更短/更整洁的方法来替换标签?

在我的例子中,我有 4 种情况我想“跳过”结尾, 当标签值结束时:

  • .ConsumerEndpointFactoryBean
  • .频道。 (以小写字母开头)
  • .频道。 (以大写开头)
  • .handler.

【问题讨论】:

    标签: prometheus grafana promql


    【解决方案1】:

    没关系,这只是正则表达式的问题

    label_replace(
        rate(spring_integration_send_seconds_count{result!="success", app="MyApplicationName"}[1m])
         ,"service", 
        "$1", 
        "name",   "(.*).(channel|Channel|handler|ConsumerEndpointFactoryBean).*"
        )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-13
      • 2021-09-30
      • 2021-01-24
      • 1970-01-01
      • 2017-12-13
      • 2020-08-03
      • 2022-12-21
      相关资源
      最近更新 更多