Prometheus 正则表达式匹配不同标签

Sat*_*mar 6 prometheus promql

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

input = ".*abc.*"

node_cpu_seconds_total{instance=~".*abc.*" or mode=~".*abc.*" or cpu=~".*abc.*"}
Run Code Online (Sandbox Code Playgroud)

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

Mic*_*bez 9

您无法使用向量选择器实现此目的,但可以使用union 运算符OR来获取选择的并集:

node_cpu_seconds_total{instance=~".*abc.*"} or \
node_cpu_seconds_total{mode=~".*abc.*"} or \
node_cpu_seconds_total{cpu=~".*abc.*"}
Run Code Online (Sandbox Code Playgroud)

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

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