Hello,
I’m collecting data using the vsphere plugin running from a central server.
This plugin collects the host name, which in this case is the central server running this plugin has “host”, “esxhost” and “vm_name”
The “host” name is the name of the central server running telegraf, which isn’t too meaningful in our alerts
When an alert is created, we send the data to an API (we’re using MS automate) we get the alert payload which contains both values. I want to get the tag value for “esxhost” or “vmname” and assign it to a new variable “host_actual”
i then want to use this variable to create a new tag that is sent to my API so we get “host: host_actual” - This would have the value of either the esxhost or the vm being monitored but means we would have consistent tag name in our workflow.
I’m struggling to do this though, I’ve declared a new variable in my script
var host_actual = '{{index .Tags "esxhost}}
I then pass this to a lambda expression to convert it to a string and save it as a tag.
The problem I’m having at the moment is no matter how i try to evaluate host_actual i either get
- {{index .Tags “esxhost”}}
OR
simply the value “host_actual”
I’ve tried single/double quotes. no quotes, I’ve added a |default node to try and do this but i get the same values as above which makes me think that its a problem with the variable?
Now, i KNOW i can add .tag() to the end of my influxDBOut node which should insert the tag value into my database (though i think at the moment i might end up with the same result), however i don’t want to keep this tag in my data. Its sole purpose is being sent to the API.
Unfortunately the JSON parser in MS automate isn’t as smart as we’d like, the only way we’ve found to get the data in there without really complex work flows is to convert the fields to tags, send them to the API and then drop the new tags before being written to a database.
Any idea how i can do this?
PhilB
Edit: the fields we are converting to tags is working fine, its just this one