Health-check dependency

I’m following the health check section and I’m stuck on applying the dependency “health-checks” to all of the services.

apply Dependency "health-check" to Service {
  parent_service_name = "child-health"

  states = [ OK ]
  disable_notifications = true

  assign where host.vars.client_endpoint
  ignore where service.name == "child-health"
}

The error message that I’m receiving is:

**critical** /config: Error: Dependency 'icinga2-client.localhost!ssh!health-check' references a parent host/service which doesn't exist.

Since there is a “parent_service_name” variable, am I supposed to make an empty service for “child-health”? I’m not sure what should go here and I can’t find any resources that explains this.

apply Service "child-health" {
  import "generic-service"
  command_endpoint = host.vars.client_endpoint
}

You do need a parent for dependencies, it is what triggers it.
If you had a Service child-health on a Host and the client_endpoint the Dependency will apply to all other Services of that Host and disable notifications when child-health goes down.

Vice versa, every Host with client_endpoint set now also needs a child-health Service. But instead of adding an empty service with that name that does not do anything, you can modify your assign where with an additional match like
assign where host.vars.client_endpoint && host.vars.check_health and set check_health on the Hosts you want to have a dependency.

There’s a typo in the docs - the above example marks the service as cluster-health which should be used in the dependency - the service which executes the cluster-zone checkcommand should be used as parent.