This is the first I’ve heard of recording rules. So I would be able to
convert the group_right query into a new metric using this method?

The documentation seems to suggest it’s a colon string with an expression.
Does that mean the metric becomes the string containing the colons? And I
guess these need to exist within the rule files like for alertmanager?

I think doing that would be a better solution however still need to work
out the issue with not returning a zero value. I understand the
premise of ‘ foo
or on (x,y,z) bar * 0’ but not enough to be able to substitute the metrics
and labels from my existing count by, are you able to provide further
guidance on that?

Massively appreciate your help

Thanks
Nick

On Tue, 7 Mar 2023 at 15:26, Brian Candler <b.cand...@pobox.com> wrote:

> > My issue with the above is that I don't have the
> `ltmPoolMbrStatusAvailState` metric with both the
> `ltmPoolMbrStatusAvailState` and `ltmPoolMbrStatusEnabledState` label
> values. Im not sure how I would manage to get the merged metric in this way.
>
> You can nest queries as far as you need, including the
> group_left/group_right query shown before.  And if that makes them
> unmaintainable, you can use recording rules to generate new metrics
> containing the results of those queries.
>
> > The other issue is that queries 2,3 and 4 will not return a 0 value if
> for example on number 2 there are no members that ARE available AND are NOT
> enabled, so no value is returned, im not sure how that would be handled in
> the maths operation as it would likely be "no data" rather than 0.
>
> count(foo) counts the number of elements in instance vector foo, and if
> it's an empty vector it returns 0.
>
> BUT: count by (foo) (bar) will only give a unique count for each value of
> the 'foo' label in the 'bar' metric (with missing/empty foo label counted
> as a separate value).  If there are no 'bar' metrics at all, then you'll
> get an empty result set.
>
> If there is *some* metric "bar" that you can depend on always being
> present, then you can do something like
>     foo or on (x,y,z) bar * 0
>
> Bear in mind that things which *look* like Boolean operations in PromQL,
> aren't.
>
> foo < 50      # return the instance vector "foo" trimmed to include only
> those timeseries whose value is < 50 (i.e. it's a filter)
>
> foo or bar   # union of all values of "foo", plus those values of "bar"
> which don't have exactly matching label sets in "foo"
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Prometheus Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/prometheus-users/qlHK7r1hQVs/unsubscribe
> .
> To unsubscribe from this group and all its topics, send an email to
> prometheus-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/55b0403a-37b6-4cfc-80a2-0dde13266233n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/55b0403a-37b6-4cfc-80a2-0dde13266233n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prometheus-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAC4WY5-b5cMJ_6THgHPx6GcDPiTyGiFGPucnOzvwSLp23JcX2w%40mail.gmail.com.

Reply via email to