I have a counter in prometheus
I want to plot it's raw value, but accounted for resets, i.e. if it goes
raw: 0 1 4 6 1 3 4
res: 0 1 4 6 7 10 14
^
reset
And then I want also subtract the value at left point, so I'll get the growth over time in the selected interval
I was able to do this with this expression:
increase(counter[1y]) - (increase(counter[1y] @ start()))
Where 1y
is something very large, so the increase will count every point
There are two problems:
- It's quite inefficient, and takes some time
- It also includes labels for non existent in interval data (i.e. if there was a
counter{foo="foo"}
long time ago, it will not have any points, but still appear in legend in grafana
I can kinda solve the second problem with
(increase(counter[1y]) - (increase(counter[1y] @ start()))) > 0
It will also filter actual points with zero values, but I can live with it
But this seems like a very basic aggregation, and I'm thinking I'm doing something wrong, but I couldn't figure a better way to count this.
Is there a better way?
UPD:
This is what I want (and have)
This is just increase(..[$__range])
This is increase(..[$__range]) - increase(..[$__range] @ start())
Notice, that in my desired picture all the plots go only up