What language do Kapacitor's alert message templates use?

902 views Asked by At

When I send an alert through Kapacitor, either by defining one directly in TICKscript or by configuring one in Chronograf, I get to specify a Message using a template syntax. However, this syntax isn't documented in any great detail at https://docs.influxdata.com/kapacitor/v1.3/nodes/alert_node/#message; instead, the docs just provide a few examples.

What language are these templates even written in? Does the language have a name? Any documentation? How does its syntax work, and what can I do with it besides simply template in the variables listed in the docs?

1

There are 1 answers

1
Bunyk On BEST ANSWER

Well, since Kapacitor is written in Golang, it would be safe to assume that that are Golang templates, and they are indeed, as we could see in sourcecode.

What else you could do besides just embedding variables? Well, lots of stuff, check the documentation: https://golang.org/pkg/text/template/

For example, iterate over tags:

{{ range $tag_key, $tag_value := .Tags}} {{$tag_key}}={{$tag_value}} {{end}}