2

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!

Shvalb
  • 1,835
  • 2
  • 30
  • 60
  • Well, the name of the field is "value" isn't it? So you already kind of have it. Or I don't understand your question. – Bunyk Jul 23 '18 at 08:52
  • I just interested to get it programatically – Shvalb Jul 23 '18 at 18:10
  • Oh, I guess I got you. So you have some datapoints, but don't have names of fields in them? Then I guess I could answer your question. – Bunyk Jul 23 '18 at 20:24

1 Answers1

2

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}}
Bunyk
  • 7,635
  • 8
  • 47
  • 79