Here is my Chronograf generated Deadman tick script
I have a group by but the text of the e-mail sent still contains no values for
hostname
host
and service
I am having a rough time trying to use the {{ index .Tags “fieldname”}} to extract the tag values to be incorporated in the e-mail body or subject
var db = ‘telegraf’
var rp = ‘autogen’
var measurement = ‘mongodb’
var groupBy = [‘host’, ‘hostname’, ‘service’]
var whereFilter = lambda: (“host” == ‘wwwww.homedepot.com’) AND (“hostname” == ‘xxxxxxx.homedepot.com’) AND (“service” == ‘yyyyy’)
var period = 1m
0s
var name = ‘MongoDB Deadman’
var idVar = name + ‘:{{.Group}}’
var message = ’ Level: {{.Level}} hostname: {{ index .Tags “hostname” }} host: {{ index .Tags “host” }} service: {{ index .Tags “service” }}’
var idTag = ‘alertID’
var levelTag = ‘level’
var messageField = ‘message’
var durationField = ‘duration’
var outputDB = ‘chronograf’
var outputRP = ‘autogen’
var outputMeasurement = ‘alerts’
var triggerType = ‘deadman’
var details = ‘Level: {{.Level}}
hostname: {{ index .Tags “hostname” }}
service: {{ index .Tags “service” }}
host: {{ index .Tags “host” }}
ID: {{.ID}}
Name: {{.Name}}
TaskName: {{.TaskName}}
Group: {{.Group}}
Tags: {{.Tags}}
Level: {{.Level}}
Time: {{.Time}}
Fields: {{ index .Fields “hostname” }} {{ index .Fields “host” }}’
var threshold = 0.0
var data = stream
|from()
.database(db)
.retentionPolicy(rp)
.measurement(measurement)
.groupBy(groupBy)
.where(whereFilter)
var trigger = data
|deadman(threshold, period)
.message(message)
.id(idVar)
.idTag(idTag)
.levelTag(levelTag)
.messageField(messageField)
.durationField(durationField)
.details(details)
.email()
.to(‘’)
trigger
|eval(lambda: “emitted”)
.as(‘value’)
.keep(‘value’, messageField, durationField)
|eval(lambda: float(“value”))
.as(‘value’)
.keep()
|influxDBOut()
.create()
.database(outputDB)
.retentionPolicy(outputRP)
.measurement(outputMeasurement)
.tag(‘alertName’, name)
.tag(‘triggerType’, triggerType)
trigger
|httpOut(‘output’)