Can I create an alert in kapacitor which is triggered when the value is below a specific limit for more than 10 minutes

I want to create an alert for the system when the value is below specific limit. But I do not want it to throw alert every time it happens. I only want to create a alert when the value stays below the limit for a certain amount of time.
It could be something with the combination of threshold and relative alert where the value is below threshold AND the change in last 10 min is 0%.
But I am having difficulty in creating such alert.

Hello @ashish02,
I found some threads with code examples that might be useful to you.

Please let me know if you’re still having trouble after looking through these.
Thank you :).

Based on the thread you provided I create this relative alert. As visible in the graph the past value is 1 and current value is 0 thus the change is -1 which is less than 0. But I am not getting alert for this. Please help.

var db = ‘test’

var rp = ‘autogen’

var measurement = ‘kapacitor’

var groupBy =

var whereFilter = lambda: TRUE

var period = 10s

var every = 30s

var name = ‘Test-Alert’

var idVar = name

var message = ‘TEST TICK ALERT 10 minutes’

var idTag = ‘alertID’

var levelTag = ‘level’

var messageField = ‘message’

var durationField = ‘duration’

var outputDB = ‘chronograf’

var outputRP = ‘autogen’

var outputMeasurement = ‘alerts’

var triggerType = ‘relative’

var shift = 1m


var crit = 0

var data = stream

var past = data

var current = data

var trigger = past
.as(‘past’, ‘current’)
|eval(lambda: float(“current.value” - “past.value”))
.crit(lambda: “value” < crit)

|eval(lambda: float(“value”))
.tag(‘alertName’, name)
.tag(‘triggerType’, triggerType)