Use of alias in configuration files

Hi
first of all , iam new to icinga2
i am trying to configure icinga2 for monitoring our network devices.

i have a question about making conf files simple.

i want to manually configure which services i want to monitor, so my conf files has also object services

My question is that, is it possible to make a alias on top on configuration files that is being used on both host object and services, so i dont need to change host_name on every object…

Something like this:

Alias XXX=nameofthehost

object Host XXX {
import “generic-switch”

object Service “CPU load status” {
import “generic-service”
host_name = “XXX”

is it possible ?

Sure, you can use variables in the Icinga DSL but I never used them to define host objects but I’m quite sure I did this for services before I switched to the director.

nice, Can you give a example of it ?, i have tried few times and couldt get it to work…

What didn’t work?

What happens if you try:

alias_test = "test.example.com"

object Host alias_test  {
  import "generic-switch"
}

object Service "CPU load status" {
  import "generic-service"
  host_name = alias_test
}

It say that it could define variables before.

it seems to work with your example… thanks…