[Solved]Template definition with Chronograf triggers - has string undefined errors

Trying to create templates that leverage chronograf too, but I keep getting ‘invalid TICKscript: name “string” is undefined. Names in scope: stream,time’ It would be helpful to know the line it is objecting to not being defined, though it is my understanding the actual task will define strings.

Here is tickscript:

var measurement = string
var groups = [*]
var metric = string
var whereFilter = lambda: TRUE
var message = string
var durationField = ‘duration’
var alertName = string
var idVar = alertName + ‘:{{.Group}}’
var outputDB = ‘chronograf’
var outputRP = ‘autogen’
var outputMeasurement = ‘alerts’
var triggerType = ‘custom’
var alertURL = string
var periodTime = duration
var checkTime = duration
var warnSig = float
var critSig = float
var data = stream
|from()
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|window()
.period(periodTime)
.every(checkTime)
|mean(metric)
.as(‘stat’)
var trigger = data
|eval(lambda: sigma(“stat”))
.keep()
.as(‘sigma’)
|alert()
.warn(lambda: “sigma” > warnSig)
.crit(lambda: “sigma” > critSig)
.stateChangesOnly()
.message(message)
.id(idVar)
.levelTag(’{{ .Level }}’)
.messageField(messageField)
.durationField(durationField)
.post(alertURL)
trigger
|eval(lambda: “sigma”)
.keep()
.as(‘value’)
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag(‘alertName’, alertName)
.tag(‘triggerType’, triggerType)
trigger
|httpOut(‘output’)

Ok, figured out my issue - it is because I’m assigning variable string instead of setting it:

var measurement = string (incorrect)
var measurement string (correct)

Also, groupBy should be groups
var messageField = ‘message’ (correction)

I could use a better explanation to what ‘idField’,‘messageField’,‘durationField’, ‘idTag’ alertNode properties are really used for- the description in docs isnt so clear to the new user of said properties.

1 Like