Create Service02 for all Hosts that have Service01

Hi :wave:

I’m not sure if my intention is unusual, but I couldn’t find an answer to my question in the documentation and thought maybe I can find an answer here. I have a host and a service:

object Host "" {
  import "generic-host"

object Service "service01" {
  import "generic-service"
  host_name = ""
  display_name = "service01"
  check_command = "command01"

  vars.key01 = 500

This works so far, the host and the service are available in Icinga. Now I would like to use “assign where” to create a second service. The second service should be created for each host if:

  • The host has a service with name “service01”
  • The corresponding “service01” has the variable “key01”

I was thinking something like that:

apply Service "service02" {
  import "generic-service"
  display_name = "service02"
  check_command = "command02"

  assign where "service01" in

But this ends with:

[2023-11-10 16:19:08 +0100] critical/config: Error: Invalid field access (for value of type 'Host'): 'services'

And that doesn’t take into account the fact that I also want to check the variable.


Hello Markus!

First of all, if you have a service01 on more than one host, consider an apply rule for that. Such will have an assign rule you can copy to service02 and include the key01 there. But the latter will have to reside inside the host.


Hi @markusr,
I am not completely sure about this, but I think it is not possible to create this the way you tried here.

A Service is not part of a Host (as would be suggested with but it is almost the other way round. A Service knows it’s Host (host_name attribute).
Since apply rules can not reference other Services (I believe), setting up a Service by referencing another Service is not possible.

The way around this would be (as @Al2Klimov suggested in a way) to change your data model and put all the necessary information in the host (via the vars dictionary for example) and assign the two services independently but maybe using the same condition.

1 Like