【问题标题】:Prometheus regex match on different labelsPrometheus 正则表达式匹配不同的标签
【发布时间】:2020-06-07 16:27:26
【问题描述】:

我想在 prometheus 中根据所有标签进行过滤。假设我在 prometheus 中的标签是实例、cpu、查询 node_cpu_seconds_total 的模式,我想做一个类似的操作,

input = ".*abc.*"

node_cpu_seconds_total{instance=~".*abc.*" or mode=~".*abc.*" or cpu=~".*abc.*"}

基本上我希望我的正则表达式与所有标签值进行比较。有什么解决方案可以实现吗?

【问题讨论】:

    标签: prometheus promql


    【解决方案1】:

    您无法使用 vector selectors 实现此目的,但您可以使用 union operator OR 获得选择的联合:

    node_cpu_seconds_total{instance=~".*abc.*"} or \
    node_cpu_seconds_total{mode=~".*abc.*"} or \
    node_cpu_seconds_total{cpu=~".*abc.*"}
    

    但是没有 all label values 选择器 - 这意味着您必须指定所有标签。

    请注意,这是一种相当奇怪的请求。

    【讨论】:

    • 我有一个要求,比如在 aws 控制台中,我们如何使用我们在搜索栏中提供的数据获得结果,它会尝试匹配所有字段并给出结果。同样,我必须这样做。另外,有什么方法可以让我获得查询结果中的标签。
    • 我不知道。 grafana中可能有一些方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 2013-04-30
    • 1970-01-01
    相关资源
    最近更新 更多