What we want to achieve is to configure the message template that is used by the deadman function. The message that should be displayed should depend on the value of .Level. Two variables are created (start_summary and end_summary and message) and depending on the value of .Level either the value of start_summary or the end_summary variable should be outputted by deadman. Normally, these vars are declared vars and get their value from a JSON variable file.
Below is the template (relevant part).
The vars start_summary and end_summary are added as Tags using the DefaultNode. These vars themselves include a Tag. Depending on the value of .Level the correct message is displayed, however, the Tag in the vars is not replaced. For instance the following message is displayed:
[PROBLEM] The data measurements are missing for runtime {{ index .Tags “runtime-name” }} [Testing]
Is it somehow possible to get the Tag that is referenced by the vars start_summary and end_summary evaluated and replaced by the actual name of the runtime?
This runtime does exist as a Tag by the way.
var start_summary = ‘[PROBLEM] The data measurements are missing for runtime {{ index .Tags “runtime-name” }} [Testing]’
var end_summary = ‘[FIXED] The data measurements are missing for runtime {{ index .Tags “runtime-name” }} [Testing]’
Template:
var message = ‘{{ if eq .Level “CRITICAL” }} {{index .Tags “start_summary”}} {{ else if eq .Level “OK” }} {{index .Tags “end_summary”}} {{ end }}’
var dayRestriction lambda
var timeRestriction lambda
var qry = ‘SELECT count(*) FROM "’ + db + ‘"."’ + rp + ‘"."’ + measurement + '" WHERE ’ + whereClause
var data = batch
|query(qry)
.period(period)
.cron(qryCronExpr)
.groupBy(‘environment’, ‘runtime-name’)
|default().tag(‘start_summary’, start_summary)
|default().tag(‘end_summary’, end_summary)
var trigger = data
|deadman(threshold, interval, lambda: dayRestriction AND timeRestriction)
.message(message)
.stateChangesOnly()
.details(’’)
.post(‘http://…’)