Performing Derivative On A Stream

hi, when using kapacitor to calculate the derivative of a value on a stream do i have to use the window node with it or can the derivative node be used independently?

for example, if i’m trying to calculate the bit rate for an interface every minute on the fly should i do this:

var outOctets = stream
    |from()
        .measurement('interfaces')
        .groupBy(*)
        .where(lambda: "device" == 'ROUTER1' AND "type" == 'egress_stats.if_octets')
    |window()
        .period(2m)
        .every(1m)
    |derivative('value')
        .unit(1m)
        .nonNegative()
    |eval(lambda: "value" / 60 * 8 )
        .as('bps')
    |influxDBOut()
        .database('kapacitortest')
        .retentionPolicy('autogen')
        .measurement('router1')

or can i leave out the window node? currenlty this is not working.

1 Like

never mind, i found my problem.

had to change -------------> |eval(lambda: “value” / 60 * 8 )
to this ------------------------> |eval(lambda: int(“value”) / 60 * 8 )

1 Like