Assuming I have two different metrics with different labels names but the same a group of values :
metric1{label1="some_values_the_same_as_in_metric2"} val examples: val1 val2 val3
metric2{label2="some_values_the_same_as_in_metric1"} val examples: val2 val3
Now I want to query metric1 with label1 but filter out all metrics with the same value as in metric2 label2
I know I can metric1{label1!=~"val2|val3"}
but what if i have 300 values in metric1 and 200 in metric2 and these can change over time? how to filter it out dynamically?
tried many things like this:
metric_name1 unless metric_name2 on(common_label) group_left
but without success
Your attempt is in correct direction. It's just that
on()clause needs label common for both metrics, but based on your example, they are not.This is not a problem though:
label_replacecan help us here.Here, I copy label
label2intolabel1, and then use it inunlessto exclude all the metrics with matchinglabel1.You don't need
group_leftsinceunlesswithonclause doesn't change left operand's labels set (unlikeandwithonclause).