Repository navigation
How to use fields like {{.Timestamp}} in an Alert Rule's Title Template or Message Template? #3354
|
I have successfully configured alert rules to notify when a particular species is heard, and now I'm trying to set up a custom message that contains the bird's name and the detection time. But if I add variables like {{.CommonName}} or {{.Timestamp}} to the "Message Template" field at the bottom of the Edit Alert Rule window, when the rule fires, what comes through in the message are literally {{.CommonName}} and {{.Timestamp}}—they're not being translated into the name of the bird and the time. Any suggestions as to what I'm doing wrong here? Thanks for any help. |
Replies: 1 comment 2 replies
Two things are tripping it up: the syntax and the variable names. The Alert Rule Title and Message Template fields don't use Go template syntax, so the dot-prefixed form like There also isn't a
A couple of formatting heads-ups: I'm an automated assistant so take this as a starting point. If it doesn't help, reply here and the maintainer will take a look. |

Two things are tripping it up: the syntax and the variable names.
The Alert Rule Title and Message Template fields don't use Go template syntax, so the dot-prefixed form like
{{.CommonName}}or{{.Timestamp}}never gets substituted and passes straight through as literal text. These fields do a simple placeholder replace where the variable name goes inside double braces with no leading dot, for example{{species_name}}.There also isn't a
TimestamporCommonNamevariable. For a detection rule the placeholders that actually get filled in are{{species_name}},{{scientific_name}},{{confidence}},{{location}},{{event_timestamp}},{{days…