How to use non_negative_difference() in kapacitor alert


I want to know how to use non_negative_difference() corresponding implementation in kapacitor.
I am able to use non_negative_derivative() using following


I am also able to use difference()


But I am not able to find the implementation of non_negative_difference()
I tried to use following, but alerts are not firing correctly


Can anyone suggest right way to use non_negative_difference()


Advait Deo

Hi @Advait_Deo

is using a lambda expression in the alertNode to check if the difference is positive
a good solution for you ?

best regards

We are using following lambda function in laert

    .warn(lambda: "value" > 50)

does non_negative_difference() converts the output to positive?

value: 100
value: 80

difference() will give the output as -20
does non_negative_difference() gives the output as 20 or does it ignore it?


Advait Deo

Hi @Advait_Deo ,

`NON_NEGATIVE_DIFFERENCE()`  behaves the same as the  `DIFFERENCE()`  function but  
`NON_NEGATIVE_DIFFERENCE()`  returns only positive differences or differences that equal zero.

In this link someone found a workaround in kapacitor …

Thanks @MarcV
Below link actually uses batch query. I want to use non_negative_difference() in stream alerts. So was wondering if we have a kapacitor implemetation for the same (similar to non_negative_derivative())