# Understanding non-negative-derivative calculations

Hi,

I’m trying to understand how a specific calculation is being made in my InfluxDB instance. I’m trying to convert outOctets to bits per second. How is the non_negative_derivative on line 79 being calculated?

My data:
File:
01: > select outOctets, “name” from interfaces where time >= ‘2019-06-26T05:20:00Z’ and time <= ‘2019-06-26T05:30:00Z’ and “device” =~/router1/ and “parent_ae_name” =~/ae5/ fill(null)
02: name: interfaces
03: time outOctets name
04: ---- --------- ----
05: 2019-06-26T05:20:58.973191142Z 31302849684516400 et-3/0/0
06: 2019-06-26T05:20:58.973191142Z 31272126358248587 et-3/0/1
07: 2019-06-26T05:20:58.973191142Z 31238123042755147 et-3/0/2
08: 2019-06-26T05:20:59.07270147Z 31247196338317814 et-3/0/3
09: 2019-06-26T05:21:59.334579984Z 31302946825492410 et-3/0/0
10: 2019-06-26T05:21:59.334579984Z 31272219339496252 et-3/0/1
11: 2019-06-26T05:21:59.334579984Z 31238218870773391 et-3/0/2
12: 2019-06-26T05:21:59.429565535Z 31247288786208786 et-3/0/3
13: 2019-06-26T05:22:59.65995239Z 31303041423118589 et-3/0/0
14: 2019-06-26T05:22:59.65995239Z 31272312155334000 et-3/0/1
15: 2019-06-26T05:22:59.65995239Z 31238313778737070 et-3/0/2
16: 2019-06-26T05:22:59.760256232Z 31247381702525493 et-3/0/3
17:
18: 2019-06-26T05:23:59.975823585Z 31303135140067075 et-3/0/0
19: 2019-06-26T05:23:59.975823585Z 31272405462383594 et-3/0/1
20: 2019-06-26T05:23:59.975823585Z 31238407797812959 et-3/0/2
21: --------> missing data for et-3/0/3
22:
23:
24:
25:
26:
27: --------> missing data for et-3/0/0
28: --------> missing data for et-3/0/1
29: --------> missing data for et-3/0/2
30: 2019-06-26T05:24:00.098445796Z 31247472743136403 et-3/0/3
31:
32: 2019-06-26T05:25:00.321634529Z 31303230808206023 et-3/0/0
33: 2019-06-26T05:25:00.321634529Z 31272500077771275 et-3/0/1
34: 2019-06-26T05:25:00.321634529Z 31238503530734386 et-3/0/2
35: 2019-06-26T05:25:00.412217962Z 31247565879162886 et-3/0/3
36: 2019-06-26T05:26:00.624893325Z 31303325704964437 et-3/0/0
37: 2019-06-26T05:26:00.624893325Z 31272595573841615 et-3/0/1
38: 2019-06-26T05:26:00.624893325Z 31238601823547151 et-3/0/2
39: 2019-06-26T05:26:00.729215941Z 31247661897390271 et-3/0/3
40: 2019-06-26T05:27:00.926821237Z 31303420002893004 et-3/0/0
41: 2019-06-26T05:27:00.926821237Z 31272692630219195 et-3/0/1
42: 2019-06-26T05:27:00.926821237Z 31238699104196139 et-3/0/2
43: 2019-06-26T05:27:01.029622204Z 31247758316934124 et-3/0/3
44: 2019-06-26T05:28:01.272049087Z 31303513706213053 et-3/0/0
45: 2019-06-26T05:28:01.272049087Z 31272786036107603 et-3/0/1
46: 2019-06-26T05:28:01.272049087Z 31238796168634765 et-3/0/2
47: 2019-06-26T05:28:01.376615889Z 31247852834642408 et-3/0/3
48: 2019-06-26T05:29:01.597224604Z 31303606579433609 et-3/0/0
49: 2019-06-26T05:29:01.597224604Z 31272877926262280 et-3/0/1
50: 2019-06-26T05:29:01.597224604Z 31238893481454528 et-3/0/2
51: 2019-06-26T05:29:01.697449706Z 31247947952506561 et-3/0/3
52:
53: > select last(outOctets), “name” from interfaces where time >= ‘2019-06-26T05:20:00Z’ and time <= ‘2019-06-26T05:30:00Z’ and “device” =~/router1/ and “parent_ae_name” =~/ae5/ group by time(1m) fill(null)
54: name: interfaces
55: time last name
56: ---- ---- ----
57: 2019-06-26T05:20:00Z 31247196338317814 et-3/0/3
58: 2019-06-26T05:21:00Z 31247288786208786 et-3/0/3
59: 2019-06-26T05:22:00Z 31247381702525493 et-3/0/3
60: 2019-06-26T05:23:00Z 31303135140067075 et-3/0/0 ---------> didn’t chose et-3/0/3
61: 2019-06-26T05:24:00Z 31247472743136403 et-3/0/3
62: 2019-06-26T05:25:00Z 31247565879162886 et-3/0/3
63: 2019-06-26T05:26:00Z 31247661897390271 et-3/0/3
64: 2019-06-26T05:27:00Z 31247758316934124 et-3/0/3
65: 2019-06-26T05:28:00Z 31247852834642408 et-3/0/3
66: 2019-06-26T05:29:00Z 31247947952506561 et-3/0/3
67: 2019-06-26T05:30:00Z
68:
69:
70:
71: > select non_negative_derivative(last(“outOctets”), 60s) /60 *8 from “interfaces” where time >= ‘2019-06-26T05:20:00Z’ and time <= ‘2019-06-26T05:30:00Z’ and “device” =~/router1/ and “parent_ae_name” =~/ae5/ group by time(1m), “parent_ae_name” fill(null)
72: name: interfaces
73: tags: parent_ae_name=ae5
74: time non_negative_derivative
75: ---- -----------------------
76: 2019-06-26T05:20:00Z 12653265110.933332
77: 2019-06-26T05:21:00Z 12326385462.933332 ---------------> (line 12 - line 8) / 60 * 8
78: 2019-06-26T05:22:00Z 12388842227.6 ---------------> (line 16 - line 12) / 60 * 8
79: 2019-06-26T05:23:00Z 7433791672210.934 ---------------> “How is this being calculated?”
80: 2019-06-26T05:25:00Z 12418136864.4 ---------------> (line 35 - line 30) /60 * 8
81: 2019-06-26T05:26:00Z 12802430318 ---------------> (line 39 - ling 35) / 60 * 8
82: 2019-06-26T05:27:00Z 12855939180.4
83: 2019-06-26T05:28:00Z 12602361104.533333
84: 2019-06-26T05:29:00Z 12682381887.066668

HI @mohsin106 welcome to the community ,

the line in 79 is calculated from the lines

16: 2019-06-26T05:22:59.760256232Z 31247381702525493 et-3/0/3
18: 2019-06-26T05:23:59.975823585Z 31303135140067075 et-3/0/0

( line 18 - line 16 ) /60 * 8

best regards

1 Like

@MarcV Ah ok, I see why my logic was wrong. I was trying from these lines:

16: 2019-06-26T05:22:59.760256232Z 31247381702525493 et-3/0/3
20: 2019-06-26T05:23:59.975823585Z 31238407797812959 et-3/0/2

But now I realize why it is done the other way. Since from the query on line 53 we see lines 60 and 61 as the “last(outOctets)” that influx has selected to use to do the non-negative-derivative calculation for the 05:23 time frame.

60: 2019-06-26T05:23:00Z 31303135140067075 et-3/0/0 ---------> didn’t chose et-3/0/3
61: 2019-06-26T05:24:00Z 31247472743136403 et-3/0/3

I appreciate it. Thank you!