在promQL中嵌套查询

问题描述

我正在寻找度量标准'prom_metric2'的输出,其中输入标签为'label2',其值必须取自度量标准'prom_metric1'。

即用于后续输入查询

prom_metric1{label1="A"}

输出时间序列是:

prom_metric1{label1="A",label2="B",label3="C"}
prom_metric1{label1="A",label2="D",label3="E"}

现在,以下指标应采用上述时间序列中的label2的所有值,然后显示输出

prom_metric2{label2="LABEL_FROM_PROM_METRIC1 i.e. B and D"}

它等效于以下SQL查询

Select * from prom_metric2 where label2 IN (Select label2 from prom_metric1 where label1='A')

在promQL中有可能吗?

谢谢。

解决方法

以下解决方案工作正常:

prom_metric2 {some_label="value"} and on (label2 ) prom_metric1 {label1='A'}

参考: https://www.robustperception.io/exposing-the-software-version-to-prometheus

https://prometheus.io/docs/prometheus/latest/querying/operators/#many-to-one-and-one-to-many-vector-matches

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...