* Generic `Templates`, `timeperiods`, `downtimes` should be synchronized in a global zone as well.
* [Apply rules](3-monitoring-basics.md#using-apply) can be synchronized globally. Keep in mind that they are evaluated on each instance,
and might require additional filters (e.g. `match("icinga2*", NodeName) or similar based on the zone information.
-* [Apply rules](3-monitoring-basics.md#using-apply) specified inside zone directories will only affect endpoints in the same zone or below.
* Host configuration must be put into the specific zone directory.
-* Duplicated host and service objects (also generated by faulty apply rules) will generate a configuration error.
+* Duplicated host and service objects (also generated by apply rules) will generate a configuration error.
* Consider using custom constants in your host/service configuration. Each instance may set their local value, e.g. for `PluginDir`.
This example specifies the following hierarchy over three levels:
[command endpoint](13-distributed-monitoring-ha.md#cluster-health-check-command-endpoint)
explainations.
+[Apply rules](3-monitoring-basics.md#using-apply) put into zone directories underneath `zones.d`
+must specify the zone where they should be applied to e.g. `assign where host.zone == "dmz1-checker"`.
+
+ # tree /etc/icinga2/zones.d
+ /etc/icinga2/zones.d
+ ├── dmz1-checker
+ │ ├── hosts.conf
+ │ ├── apply_services.conf
+ ├── dmz2-checker
+ │ └── hosts.conf
+ ├── global-templates
+ │ ├── apply_services.conf
+ │ ├── commands.conf
+ ├── ha-master
+ │ └── health.conf
+ └── README
+
+Global apply rules:
+
+ # cat /etc/icinga2/zones.d/global-templates/apply_services.conf
+
+ apply Service "ping4" {
+ check_command = "ping4"
+
+ assign where host.address
+ }
+
+
+Zone-specific apply rules:
+
+ # cat /etc/icinga2/zones.d/dmz1-checker/apply_services.conf
+
+ apply Service "mysql" {
+ check_command = "mysql"
+
+ assign where host.zone == "dmz1-checker" && host.vars.db_type == "mysql"
+ }
+
## <a id="cluster-health-check"></a> Cluster Health Check