How to use host variables as field values in service templates?

Hello everybody, we are currently trying to port our Icinga2 configuration from using configs to using the Director.

At the moment I am trying to configure a Service Apply rule which populates a custom field value with a variable from a host. Using config files, this would be as easy as saying

vars.custom_service_field = host.vars.custom_host_field

But how can I achieve this using the Director, since you can’t define custom field values to be “variables”, only strings. Every input I tried so far, be it $host.vars.custom_host_field$ or just host.vars.custom_host_field got wrapped with "" and was used as a literal string.

Best regards,


This question has also been on my mind for some time.

In my scenario I would like to have the possibility to set the service_interval per check. Until now I have to create an extra service template and import it. This is very cumbersome and difficult to manage.

1 Like

Coming back to this after quite some time, but I managed to solve my use case. It is indeed possible to use host variables as custom service variables:

object Service "TestService" {
    vars.custom_service_var = "$host.vars.custom_host_field$"

or via Director, entering “$host.vars.custom_host_field$” as value for the created field.

1 Like