After creating an alert using Chronograf, I could not get stateChangesOnly to work as expected.
The alert (a host metric monitoring one) keeps alerting all the time with the same value, without changing at all.
Any ideas?
This is my current script:
var db = 'host_metrics'
var rp = 'metrics'
var measurement = 'disk'
var groupBy = []
var whereFilter = lambda: TRUE
var name = 'Disk Usage'
var idVar = name + ':{{.Group}}'
var message = 'Disk usage in host {{ index .Tags "host" }} is in {{.Level}} state because of value: {{ index .Fields "value" }}%'
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 warn = 20
var crit = 30
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "used_percent")
.as('value')
var trigger = data
|alert()
.warn(lambda: "value" > warn)
.crit(lambda: "value" > crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.slack()
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
P.D: the low values are just for testing purposes