Kapacitor WindowNode - configure based on stream data?

I want to apply window() using data from my stream to configure window’s parameters:

dbrp "snmp_trap"."default"

stream
        |from()
                .measurement('snmp_trap')
        |sideload()
                .source('file:///tmp/chronic_conf')
                .order('{{.name}}.yml')
                .field('chronic_count', 0)
                .field('chronic_period', 0)
        |where(lambda: "chronic_count" > 0)
        |window()
                .everyCount("chronic_count")
        |alert()
                .info(lambda: TRUE)
                .log('/tmp/chronic.log')

This fails with:

invalid TICKscript: line 15 char 4: error calling func "everyCount" on obj *pipeline.WindowNode: reflect.Set: value of type *ast.ReferenceNode is not assignable to type int64

Is it possible to convert field data to int64 that window().everyCount() would accept?

Hello @nekrassov,
I’m no Kapacitor export but maybe this will help?

Hello Anais,

It doesn’t like lambda there either:
invalid TICKscript: line 13 char 18: error calling func "everyCount" on obj *pipeline.WindowNode: reflect.Set: value of type *ast.LambdaNode is not assignable to type int64

The modified script:

dbrp "snmp_trap"."default"

stream
        |from()
                .measurement('snmp_trap')
        |sideload()
                .source('file:///tmp/chronic_conf')
                .order('{{.name}}.yml')
                .field('chronic_count', 0)
                .field('chronic_period', 0)
        |where(lambda: "chronic_count" > 0)
        |window()
                .everyCount(lambda: int("chronic_count"))
        |alert()
                .info(lambda: TRUE)
                .log('/tmp/chronic.log')