Hello!
I am having some problems with Kapacitor. I am testing how the alerts work, and I created a test database where a datapoint is written every 5 seconds. All the datapoints have the same value of tag=11 temp=10.
The deadmen alert, when I stop the script that loads the data, works fine, so the connection between Kapacitor and InfluxDB works.
I tried two alerts, one that should be triggered when the %change is <= 1% and one alert that should be triggered when the temp is below a threshold of 15.
The TICK script for the threshold log is the following:
var db = ‘Test_Kapacitor’
var rp = ‘autogen’
var measurement = ‘Temp’
var groupBy =
var whereFilter = lambda: (“tag” == ‘11’)
var period = 10s
var every = 30s
var name = ‘Test’
var idVar = name
var message = 'Tag: {{ index .Tags “tag” }} has a temp below 15 ’
var idTag = ‘alertID’
var levelTag = ‘level’
var messageField = ‘message’
var durationField = ‘duration’
var outputDB = ‘chronograf’
var outputRP = ‘autogen’
var outputMeasurement = ‘alerts’
var triggerType = ‘threshold’
var details = ‘Warning! Temp below 15’
var crit = 15
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|window()
.period(period)
.every(every)
.align()
|mean(‘temp’)
.as(‘value’)
var trigger = data
|alert()
.crit(lambda: “value” <= crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.details(details)
.log(‘/tmp/alert.log’)
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’)
And this is the preview graph
I already tried to select only the tag=11, to use groupby tag, to not select any tag, to add .tolerance(100ms) (this for the relative alert) and I’m running out of ideas.