var db = 'telegraf'
var rp = 'autogen'
var measurement = 'win_services'
var groupBy = []
var whereFilter = lambda: ("service_name" == 'super-duper-service')
var name = 'super-duper-service check'
var idVar = name + ':{{.Group}}'
var message = '{{ index .Tags "service_name" }} is {{.Level}} '
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 = 4
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
|eval(lambda: "state")
.as('value')
var trigger = data
|alert()
.crit(lambda: "value" < crit)
.stateChangesOnly()
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.alerta()
.resource('{{ index .Tags "host" }}')
.event('NotRunning')
.environment('{{ index .Tags "environment" }}')
.services('{{ index .Tags "service_name" }}')
trigger
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag('alertName', name)
.tag('triggerType', triggerType)
trigger
|httpOut('output')
The services() section of the Alerta config is being passed through to Alerta as a string rather than being evaluated beforehand. This is what Alerta receives:
"service": [
"{{ index .Tags \"service_name\" }}"
],
I have the following TICKscript:
The
services()
section of the Alerta config is being passed through to Alerta as a string rather than being evaluated beforehand. This is what Alerta receives:There was a similar issue fixed last year that affected the environment field: https://github.com/influxdata/kapacitor/issues/306.
Am assuming that this a bug rather than me doing something daft - would appreciate any guidance. Thanks in advance!