How to use non_negative_difference() in kapacitor alert

Hi,

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

|derivative('value')
    .unit(1s)
    .nonNegative()
    .as('value')

I am also able to use difference()

|difference('var_value')
    .as('value')

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

|derivative('var_value')
    .nonNegative()
    .as('value')
|difference('value')
    .as('value')

Can anyone suggest right way to use non_negative_difference()

Regards,

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

|alert()
    .warn(lambda: "value" > 50)

does non_negative_difference() converts the output to positive?
Example:

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?

Regards,

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())