HostGroup doesn't work

Hi, I recently configured plenty of services in .conf files so that I can monitor many NDR sensors. I tried to configure a host group so that I can’t easily assing services to sensor but it doesn’t seem to work. I tried to match host.name with regex like : assign when match(“sensor*”, host.name) and didn’t get any error while reloading daemon, nor in logs . Nonetheless when I check host manually /sbin/icinga2 object list --type Host --name sensor1 , groups list remains empty, and I didn’t managed to toubleshoot. Additionaly, native hostgroups created like ‘linux-server’ mapped on vars.os == linux doesn’t work too. Is the groups feature working well for hosts ?

Welcome to the Icinga community and thanks for posting.

I just tried to reproduce your setup and had to find out that the icinga2 object lit -t Host command also returns an empty group for my test setup. However, using the Icinga 2 API works.

curl -k -s -S -u icinga:root -H 'Accept: application/json' 'https://localhost:5665/v1/objects/hosts?pretty=1'

Could you please verify if this returns the expected groups? Otherwise, feel free to post the related configuration snippet.

Btw, I have reported this upstream, https://github.com/Icinga/icinga2/issues/10348.

Practical tip here:
Please do not assign Services based on HostGroups. It confuses things and will clutter your HostGroups in the Webinterface with awfully specific stuff you don’t want to see.

Use some something like:

object Host "sensor01" {
....

  vars.sensortype = "Senseit 3000"
}

and a Apply rule:

apply Service "Sensor foo " {
...
assign where host.vars.sensortyp == "Senseit 3000"
}
1 Like

Hi ! Thanks for your reply !! Revealed very helpful, I finally used a custom vars assigned to my sensor hosts, that I used to define services as depicted below and works pretty well

Hi ! I’ve just implemented the solution with custom vars that you recommended, a nd it worked well ! Thanks for your help !