which of course doesn’t work because an array of strings doesn’t implicitly convert to a string.
I tried
"host.groups="+host.groups.join(",")
but that doesn’t work in different syntax variants (validation error “Invalid Field Access”). I also cannot pull host.groups into a local variable with the same error message.
What am I doing wrong? What is the correct syntax?
this was considerably more advanced. After grilling my head inside runtime macros, configuration varables, scopes, functions and the excellent docs I came up with this working solution:
command = [
"/etc/icinga2/bin/notify",
...
"host_groups=$notification_hostgroups$",
...
]
vars.notification_hostgroups = {{
var groups = macro("$host.groups$")
return groups.join(", ")
}}
The idea was pulled from the “functions as custom variables” section in the “Monitoring Basics” chapter of the docs. I fail to see why this is “basic” in any form, but ymmv