Hello Team, i have created my alert under kapacitor.
Now i can set my alert for Disk , memory and CPU on slack and log function() . I was able to edit my alert in chronograf but only in Stream mode .
so far so good i can edit the alert and update the TICKscript variable.
now i faced a issue ti have updated my SQL and the alert was not triggered in batch mode and idon’t know why .
i’m pretty confused about the TICKScript language.
here my config:
ar db = 'sys_metrics'
var rp = 'one_month'
var measurement = 'cpu'
var groupBy = ['host']
var whereFilter = lambda: ("cpu" == 'cpu-total') AND isPresent("usage_idle")
var name = 'CPU alert'
var idVar = name
var message = 'ttt'
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 crit = 80
var period = 10s
var every = 10s
// A circular rewrite
var data = batch
|query(''' SELECT 100 + mean(usage_idle)*-1 AS stat FROM "sys_metrics"."one_month"."cpu" WHERE cpu = 'cpu-total' ''')
.period(period)
.every(every)
.groupBy('host')
|eval(lambda: "stat")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" > crit)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.log('/tmp/CPU_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')