kapacitor

Kapacitor: How to get Field name in TICK script


I'm trying to create a TICK script via Chronograf and it works nicely. I have some tags set and some fields. I created an Alert tick file for specific field and I can get its value by doing

{{ index .Fields "value" }}

but I can't get its name...is that even possible?

Thank you!


Solution

  • Fields is a map from string to interface (see source). So you could iterate over that mapping using following template:

    {{ range $key, $value := .Fields}}
        Arbitrary text here, but you could for example show all fields
        in the form {{$key}}={{$value}}
    {{end}}