Reputation: 921
Is it possible to use the value of some metric as the value of label of another metric?
Let's say I have two metrics: metric_a
and metric_b
. metric_a
also has some_label
label. I'd like to make a query like the following:
metric_a{some_label=metric_b}
Upvotes: 1
Views: 3674
Reputation: 10114
You can, although it's quite the hack:
metric_a and count_values without() ("some_label", metric_b)
The count_values
function is going to essentially add a some_label
label to your metric_b
, equal to metric_b
's value. The actual value is going to be 1, but you're not interested in that, just in constructing the right labelset to filter your metric_a
by.
Also, you may need to pay attention to how you represent your value. E.g. there are more ways of representing the value 1 ("1"
, "1.0"
, "1e0"
etc.) and count_values
will only produce "1"
as output.
Upvotes: 4
Reputation: 34172
You can't use metrics like that, however if you want to specify metric_a
that shares a label value with metric_b
you can do:
metric_a and on (some_label) metric_b
Upvotes: 4