I have the following tickscript:
batch
|query(’’’
SELECT mean(“used_percent”) FROM “telegraf”.“default”.“swap” WHERE time > now() - 15m AND host =~ //
‘’’)
.period(15m)
.every(5m)
.groupBy(time(30s),‘host’)
|alert()
.id(’{{ index .Tags “host” }}’)
.message(’{{ .Level }}*: {{ .ID }}
Swap: {{ index .Fields “mean” | printf “%0.2f” }} ‘)
.details(’’’
Host Name:{{ index .Tags “host” }}
Severity: {{ .Level }}
Swap: {{ index .Fields “mean” | printf “%0.2f” }}
Time : {{ index .Time }}
‘’’)
// Compare values to running mean
.crit(lambda: “mean” > 90)
.stateChangesOnly()
.noRecoveries()
.slack()
.username(‘Telegraf Non Prod Alert’)
.iconEmoji(’

which fills the logs with thousands of these messages:
ts=2020-01-31T18:34:48.600Z lvl=error msg=“failed to realize reduce context from fields” service=kapacitor task_master=main task=telegrafswap_alerts node=max2 err=“field “mean_used_percent” missing from point”
How can I make it so these alerts work properly, without flooding my logs. I tried FILL(null) which didn’t seem to help