Using non_negative_derivative() with implied first value of 0


#1

Hi,

I am a new user of influxdb. I believe I did all the appropriate research before posting here, but if I missed something please point me at it. I am using influxdb 1.5.2.

I am ingesting counters which increase monotonically except when they are zeroed. So, the points might look like this, where below all have the same tags:

time counter
3 2
4 7
5 12
25 1
26 8
27 20

Where the counter did not exist at times 1-2, 6-24, or >=27.

I would like to calculate the non-negative difference between subsequent points, but with the caveat that a missing measurement should be counted as 0. So I want to get output like this:

time difference
3 2
4 5
5 5
25 1
26 7
27 12

but “select non_negative_difference(counter,1s) as difference” or similar behaves as advertised and gives me 4 differences instead of 6, omitting the ones at time 3 and time 25.

Does anyone have any suggestions?

thanks!