Kapacitor not triggring relative alert


I created a realative alert which should trigger when current value - past value >15.
But I am not getting any alert. Threshold and deadman alert are working fine. I have tried almost several conditions that should have resulted in alert but wasn’t successful.

var db = 'ashish'

var rp = 'autogen'

var measurement = 'test3'

var groupBy = []

var whereFilter = lambda: TRUE

var name = 'test3 alert'

var idVar = name

var message = 'test 3 alert'

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

0s

var crit = 15

var data = stream
    |from()
        .database(db)
        .retentionPolicy(rp)
        .measurement(measurement)
        .groupBy(groupBy)
        .where(whereFilter)
    |eval(lambda: "new")
        .as('value')

var past = data
    |shift(shift)

var current = data

var trigger = past
    |join(current)
        .as('past', 'current')
    |eval(lambda: float("current.value" - "past.value"))
        .keep()
        .as('value')
    |alert()
        .crit(lambda: "value" > crit)
        .message(message)
        .id(idVar)
        .idTag(idTag)
        .levelTag(levelTag)
        .messageField(messageField)
        .durationField(durationField)
        .stateChangesOnly()
        .slack()
        .channel('TestGrafanaAlerts')

trigger
    |eval(lambda: float("value"))
        .as('value')
        .keep()
    |influxDBOut()
        .create()
        .database(outputDB)
        .retentionPolicy(outputRP)
        .measurement(outputMeasurement)
        .tag('alertName', name)
        .tag('triggerType', triggerType)

trigger
    |httpOut('output')

I had the same problem, it turned out join is not working if there is some irregularity in timestamps, using tolerance should help:

var trigger = past
|join(current)
.as(‘past’, ‘current’)
.tolerance(100ms)

see also: https://github.com/influxdata/chronograf/issues/2011

@Cezary Were you able to solve this issue?

@ashish02 Have you tried adding the tolerance(100ms) like @Cezary suggested?