I am looking for the output of metric 'prom_metric2' where input label is 'label2' the value of which has to be taken from metric 'prom_metric1'.
i.e. for followng input query:
prom_metric1{label1="A"}
Output time series is :
prom_metric1{label1="A",label2="B",label3="C"}
prom_metric1{label1="A",label2="D",label3="E"}
Now, the following metric should take all the values of label2 from above time series and then show the output.
prom_metric2{label2="LABEL_FROM_PROM_METRIC1 i.e. B and D"}
It is equivalent to following SQL query :
Select * from prom_metric2 where label2 IN (Select label2 from prom_metric1 where label1='A')
Is this possible in promQL?
Thanks in advance.
The below solution is working fine :
prom_metric2 {some_label="value"} and on (label2 ) prom_metric1 {label1='A'}
References: 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With