Servicegroup definition (?)

Dear community,

i have a little issue, with the migration from Icinga 1.8.4 to Icinga 2, with the servicegroups.
Our old definition looks like :
define servicegroup{
servicegroup_name Test

So we got our Host with the Service-check.

But how i can migrate it to the new Icinga 2, with the “assign where” rule in the groups.conf file
The documentation dont gives any information about it.

Best regards,


how do your service objects/apply rules and hosts look like? That would help to get a better idea what you’re trying to achieve here. Is it about all services with a specific name being put into such a group, or do you follow a different pattern here? (Hint: Group assign is explained in the docs).


I think the most efficient way is to set some vars in your service objects. Based on these vars, you can create servicegroup apply rules. You don’t have to use vars - you can also apply based on the check_command (see my example below).

Having this, newly added service objects are automatically (if you set the vars accordingly) added to the servicegroup.

For example, I have different disk check commands. I’ve created one servicegroup object for all of them:

object ServiceGroup "disk" {
  display_name = "Disk Checks"

  assign where match("disk*", service.check_command) || match("check_disk*", service.check_command) || match("*/check_disk", service.vars.by_ssh_command)

Maybe it’s a bit clearer having an example for hosts:

object HostGroup "proxmox-vms" {
  display_name = "Proxmox-VMs"

  assign where host.vars.vm == "proxmox"

object HostGroup "proxmox-lxcs" {
  display_name = "Proxmox-LXCs"

  assign where host.vars.lxc == "proxmox"

The hosts get included to the hostgroups if defined like the following:

object Host "ansible.lan" {
  import "generic-host"

  address = ""

  vars.os = "Linux"
  vars.lxc = "proxmox"

object Host "docker1.lan" {
  import "generic-host"

  address = ""

  vars.os = "Linux"
  vars.vm = "proxmox"

So when I create another lxc container it is sufficient to set the vars.lxc variable to “proxmox” to get that new host assigned to the “proxmox-lxcs” hostgroup.

1 Like

Dear Michael and Bernd,
i don’t want to configure the checks automatically. Our old Configuration looks like this:

define servicegroup{
	servicegroup_name	Test_servicegroup
	alias			Test_servicegroup
	members			SERVER1,PING,\\

Can i migrate it like this: (?)

object ServiceGroup "Test_servicegroup" {
  display_name = "Test_servicegroup"

  assign where == "SERVER1" || assign where  match("PING",service_name]
  assign where == "SERVER1" || assign where  match("CPU-Load",service_name]
  assign where == "SERVER1" || assign where  match("JWALK",service_name]
  assign where == "SERVER1" ||assign where  match("DISK",service_name]
  assign where == "SERVER1" || assign where  match("FTP",service_name]

  assign where == "SERVER2" || assign where  match("PING",service_name]
  assign where == "SERVER2" || assign where  match("CPU-Load",service_name]
  assign where == "SERVER2" || assign where  match("JWALK",service_name]
  assign where == "SERVER2" || assign where  match("DISK",service_name]
  assign where == "SERVER2" || assign where match("FTP",service_name]


Best regards


the more assign where expressions are chained together, the slower the overall configuration validation becomes. Avoid that at all cost, and consider a more simple solution.

Is there a specific reason to only match this on SERVER1 and SERVER2? I’d rather recommend building something like this for service names - all hosts being added later, with their services, will become part of this automatically.

Longer version for better understanding:

assign where == "PING"
          || == "CPU-Load"
          || == "JWALK"
          || == "DISK"
          || == "FTP"

This always uses in a duplicated fashion. The algorithm can be optimized by using a list of service names and let Icinga just evaluate whether the name is in there or not.

Simplified logic with a list and the in operator:

assign where in [ "PING", "CPU-Load", "JWALK", "DISK", "FTP" ]



1 Like


my example wasn’t the best i think, the main problem is that, there are a lot of checks for a special software from us. And there are some hosts, with complete different checks, they have to be together to monitor the backend of the software.
So it is important for me, that i can connect one host, with one service_check_command, with another host and one service_check_command.
I can’t post the complete orignal configuration, cause it would be against our data privacy.

The question is, is there an easy way, like in Icinga 1.8. just to add the services from one host to a servicegroup, without any assign-rules?

Best regards


wondering why you need so many service groups in general then … is it for better visualization in your frontend? Modern best practices involve custom variables and host groups.

If the service groups are for instrumenting a different combined cluster check, I would truly recommend to define a custom variable (or more) and rely on that.

Icinga 2 doesn’t support direct group members via a long list of names and name tuples. Either use the assign rules, or specify the service group membership via the groups attribute directly on the service object.


I found a better solution, and this would is Icinga Buisness Process Modelling, that is what we needed. But thanks for your help!

Best regards

Ah ok. I would have come to that after getting towards the check direction. Next time, please mention that intention sooner :slight_smile:


Michael already covered the performance issues about your assign rules. I just like to add some notes about the syntax if someone likes to copy some parts of your snippet.

You can replace match("PING",service_name] with == "PING" if you don’t need wildcard pattern matching (you don’t use * or ?).

|| in assign rules means or. So when you specify assign where == "SERVER1" || == "PING" the service group is assigned if the host name matches or the service name (or both). I think what you originally meant was assign where == "SERVER1" && == "PING" (only assign if both conditions evaluate to true using the && operator).

Kind regards,

1 Like

Is there any way to create a group where there are hosts and services at the same time?
Every time we deploy I have to downtime the host and http services, specifically looking for strings in a few specific pages.

object HostGroup "FS-Deploy-PROD" {
display_name = "FS Deploy PROD"
assign where match ("*prodfs.*", || match ("*HAProxy*", || match ("*fs5*", host.vars.website_name)

Hi @vbits
I would like to ask you to open a new topic for your question instead of replying to an old one like this. That way you inrease the chance of people seeing (and replying) to your question and it is a lot less likely to be overlooked.
Thank you!