General notification rule for notification groups

Hello all,

We are using Director (1.8.0). I have a general question regarding notification rules.

Right now, we have notification rules for each group stating that:

host.vars.notification_groups contains “specific group name”

service.vars.notification_groups contains “specific group name”

I am trying to figure out if it is possible to create a general rule for all contact groups without the need to create 2 notification rules for each group (host and services).

Best regards,
IT guy

I think there is something like that in the newest director (1.11):

  • FEATURE: notifications can pick user(groups) from host/service vars (#462)

https://icinga.com/docs/icinga-director/latest/doc/82-Changelog/

We do it this way via the *.vars.teams variable on hosts and/or services:

apply Notification "notification-host-mail" to Host {
    import "116-tpl-notification-host-mail"

    assign where host.vars.teams
    user_groups = host.vars.teams
    vars.notify_mail_icingaweb2_url = "https://icinga.example.com/"
    vars.notify_mail_recipient = "$user.email$"
    vars.notify_mail_notes_url = "$service.notes_url$"
}

apply Notification "notification-service-mail" to Service {
    import "116-tpl-notification-service-mail"

    assign where service.vars.teams
    user_groups = service.vars.teams
    vars.notify_mail_icingaweb2_url = "https://icinga.example.com/"
    vars.notify_mail_port = "25"
    vars.notify_mail_recipient = "$user.email$"
    vars.notify_mail_server = "localhost"
    vars.notify_mail_notes_url = "$service.notes_url$"
}

apply Notification "notification-service-mail" to Service {
    import "116-tpl-notification-service-mail"

    assign where host.vars.teams && ! service.vars.teams
    user_groups = host.vars.teams
    vars.notify_mail_icingaweb2_url = "https://icinga.example.com/"
    vars.notify_mail_port = "25"
    vars.notify_mail_recipient = "$user.email$"
    vars.notify_mail_server = "localhost"
    vars.notify_mail_notes_url = "$service.notes_url$"
}

This file lives outside of the director at /etc/icinga2/zones.d/global-templates/notifications.conf and allows to fall back to the host’s teams if none are set for each service.
In the director we use data fields, data fieldcategories and data lists to comfortably configure the teams like this:


This will result in a host configuration that looks like this:

object Host "host.example.com" {
    ...
    vars.criticality = "B"
    vars.teams = [ "Entwicklung_Monitoring" ]
    ...
}

The Teams map to user groups that got imported into the director from active directory - see Active Directory/LDAP User & Group Imports via Director - #6 by PerPilot.