jenny
jenny

Reputation: 105

How to calculate the hourly Max over a month, promql

I have the following query, intended to calculate for each hour the max value, over a month. The final result should be- for each parentnode, the hourly max over the last month

I have this for now:

max_over_time((node_memory_MemTotal_bytes{site="fra",parentnode="compute_node"} - node_memory_MemFree_bytes{site="fra",parentnode="compute_node"} - node_memory_Cached_bytes{site="fra",parentnode="compute_node"} - node_memory_Buffers_bytes{site="fra",parentnode="compute_node"} - node_memory_Slab_bytes{site="fra",parentnode="compute_node"})[1h])

Thank you.

Upvotes: 0

Views: 1341

Answers (1)

trallnag
trallnag

Reputation: 2386

You will either have to use subqueries (blog post) or recording rules (example) to first calculate the avg per hour for a month and then max over time for a month.

With subqueries your query would look like this:

max_over_time(avg_over_time(node_memory[1h])[30d:5m])

You can play around with the resolution. But I recommend recording rules once you have worked out your panels

Upvotes: 1

Related Questions