How can I set a field to null in kapacitor?


Is it possible to set a field value to null, that will be written back to Influx as a null field value in the database?
Basically I have some logic that I want to work like this:

lambda: if (“x”==0, ‘null’, float(num/x))

I’ve tried various things but the closest I can get results in errors like this:
error calling “if”: Different return types are not supported - second argument is string and third argument is float64

Any suggestions?


No, this is not possible. Currently lambda expressions do not support any kind of null type. What is the larger use case?


I’m creating a new summary metric in a streaming task that is the result of dividing two other metrics, and then writing it back to a new measurement. If the divisor is 0 I want to write null there. Maybe I can find a way to simply exclude that metric in that case, which will probably have the equivalent result.


I got a very similar issue where i use the percentage example to calculate rate of events. Sometimes there is no result for my queries because there were no results and therefore my division fails. Is there a way to handle such empty query results in the evaluation?