How to use stateDuration?

We upgraded kapacitor to 1.3.0~beta2, and tried to use stateDuration to alert when the event last more than 3 minutes.
when expression evaluated as false, the stat duration value was -1, and when evaluated true, it changed to 0, but didnot increase anymore, just stay as 0
Is this the right node to use? and how should i use it? thanks.

var response_data = stream

|stateDuration(lambda: int(“result_status”) != 1 )
.crit(lambda: “resultstatus_events_duration” > 3 )
.message(‘http result error’ + string(arp))
.event(’ {{ index .Tags “domain” }} http result error’)

Also interested in using this but haven’t had time to try it yet. Looking at the PR it is named “stateCount” and from there I found the documentation.

Ah, there’s also stateDuration.

Hey @wwshi looking through the documentation, it seems that for each consecutive point for which the expression evaluates as true, the state duration will be incremented by the duration between points. This means that if the value only ever evaluates toggles between true and false all that we’ll see is 0 and -1 for the associated durations. To get actual numeric values we’ll have to have multi points where lambda: int("result_status") != 1 evaluates to true in succession.