Hi,

When you say "current month", I guess you care about the time window
starting exactly at the beginning of the calendar month, not an arbitrary 4
weeks ago?

In that case, you would have to manually choose the time window just large
enough (relative to the overall query evaluation timestamp) to only go back
exactly to that time.

There's also a complex construct you could write using a subquery to select
a rack power output only for those timestamps within the subquery that fall
into a given month, but I'm not sure you want to go that far, and it
introduces other potential issues, such as skipping over raw underlying
values in case you don't choose the subquery resolution high enough. It's
also more expensive.

In any case, I'm thinking of something like:

round(
  max_over_time(
    (
        rack_max_power_watts{job="Max power on path /racks/max-power"}
      and on()  # Filter rack power watt values down to only those from
October
        month() == 10
    )[5w:]
  )
)

...where 10 is the current month (October) and the 5w window is chosen
generously to always cover at least a full month going backward from now.

Cheers,
Julius

On Wed, Oct 5, 2022 at 10:27 AM fiala...@gmail.com <fialamar...@gmail.com>
wrote:

> Hi,
>
> It is possible to get maximum value in current month?
>
> My query is:
> round((max_over_time(rack_max_power_watts{job="Max power on path
> /racks/max-power"}[4w])
>
> Thank you.
>
> --
> 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/11446946-70b1-4d49-a411-8f0cc8df735en%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/11446946-70b1-4d49-a411-8f0cc8df735en%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Julius Volz
PromLabs - promlabs.com

-- 
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/CAObpH5ykb3ZHKZQ8P-5HGr5v-Vc5eVA5E%3DAmu9QsKixQqR46Pw%40mail.gmail.com.

Reply via email to