Is there any function in grafana if we need to add the previous value to current value and sum up the whole value.
I have used increase and sum function but the I am observing same value.
I need to get the count of all the above data points in the screenshot
Use Total
in your legend - you already have Last, First
there.
Hi,
You can use function sum_over_time
with prometheus. Guessing your query looks something like
sum(increase(...[1m]))
, your new query would look like sum_over_time(sum(increase(...[1m]))[t1:t2])
where t1
is how long behind you’d like to look (e.g. if you want to sum points from an hour, you’d pass 1h
) and t2
is the datapoint interval (every how much time points should be displayed). Without getting into details, I find the best (and most reliable) results when you have t2
set to the same value as the one right after the increase
function.
Alternatively, you can calculate how much your counter has grown up by extending increase’s lookbehind window. If you want to get the increase in one hour, you can calculate increase(...[1h])
.
Or, if you only want to display it on legend without changing your plot, try what jangaraj suggested - add Total
in your legend values (or Count
if you want the count of the points but I don’t think that’s what you’re really after ).