For example if I have two time series like below.
metric_1{id=1} 1
metric_1{id=2} 1
metric_1{id=3} 1
metric_2{id=1} 1
metric_2{id=3} 1
I would like to get this as the query result since id=2
is not in metric_2
.
{id=2} 1
Similar to this question Comparison Query to Compare Two SQL Server Tables but in Promql. Thanks for any help.
So you basically want to drop all series in metric_1
that have a value for the label id
that can be also found in the series metric_2
. In SQL this would look something like this:
metric_1 left outer join metric_2 on id
In Prometheus first you might come across group_left
. (read more about this here "Left joins in PromQL". But this will not work. Instead, we use the unless
operator.
metric_1 unless on (id) metric_2