Calculate increase of a maximum over last 24h

Hi all,

it´s probably (well most probably) a noob question, but that´s because I really AM a grafana noob :smiley:
I´ve got a max value (at the moment 48543 kg) that increases every day (a few times over the day) by a few kg since > 13 years.
Now I want to show a graph with the daily (last 24h hours) increase.

Can anyone give me (or hint at) the formula I need for this ?

Many thanks in advance and greetings,

Julian

Hi @wurzelseppi

What is your datasource and can you share your current query?

Hi there, datasource is prometheus.

The metric ist just one value ( max ), which increases over the day … I want to display the average increase to that max value over the last 24h continuesly

I believe you can use the rate() function to calculate the per-second rate of increase and then use other functions to aggregate and display the average. Here’s an example PromQL query:

avg_over_time(rate(your_metric_name[24h])) * 60 * 60

Explanation:

  • rate(your_metric_name[24h]): This part calculates the per-second rate of increase for the specified metric over the last 24 hours.
  • avg_over_time(...): This function calculates the average over the specified range. In this case, it calculates the average rate of increase over the last 24 hours.
  • * 60 * 60: This part converts the rate from per-second to per-hour, as we are calculating the average increase over a 24-hour period.

Hi, sorry, was away for some weeks.
This my solution, and it´s mind grinding easy :smiley:

increase(<metric_name>[1w])/7

Gives me the average dayly increase of the metric within one week