Can't get first line of service.output as summary for notification

Hello everybody,

For my icinga2 installation I came up with the idea to improve the notifications with a dynamic “Summary”. I was hoping somebody did that already, but I can’t find anything similar so far.
After a lot of reading and trying to adapt slightly similar ideas and solution, I’m stuck and would like to ask for help. I must add, that this is my first attempt to work with macros and that kind of dynamic stuff, so very likely I totally misunderstand that so far.

The past and what worked so far

  • every service has a field “Summary”
  • this field “Summary” is filled with a static text like “CPU load too” or “Memory utilization too high”
  • in my alarm dashboard the column summary is filled with that text

So that was pretty straight forward. Take the variable behind that field of the service and send it as summary together with service state, service output and so on.

What I can’t get working

The plugins I use (mostly written myself) create a lot of output and have some kind of summary in the first line and I would like to use this information in the alarm dashboard in the column “Summary”.

My first attempt was:
Writing the following into the “Summary” field of the service (which is then used by the notification) via Icinga2 Director :

{{ get_service($host.display_name$, $$).last_check_result.output.split("\n")[0] }}

In the dashboard I saw:

{{ get_service(deviceXY, Vitality_Check).last_check_result.output.split("\n")[0] }}

I checked the forum and icinga2 documentation again and noticed that other users edited their notification commands for some output manipulation. So …

I thought this will definitely work (but didn’t either)

I edited my notification command and changed the old value for “notification_summary” that worked before, but was static.
The old value was:
notification_summary = "$service.summary$"

The new, not working command (shortened) currently is:

object NotificationCommand "notification-service-dashboard" {
    command = [ SysconfDir + "/icinga2/scripts/" ]

	arguments += {
		"--dashboard_hostname" = {
			required = true
			value = "$dashboard_notification_address$"
		"--dashboard_port" = {
			required = true
			value = "$dashboard_notification_port$"
    vars += {
		notification_hostname = "$$"
		notification_service = "$service.display_name$"
		notification_summary = {{
			var summary = macro("$service.output$").split("\n", 1)[0]

			return summary

		notification_severity = "$service.state_id$"
		notification_message = "$service.output$"

The command icinga2 daemon -C ran successful and the deployment of the modified command was successful as well.
But after this change the notification was not send at all.

Where am I wrong here? Am I even on the right path or completely wrong with my attempts?

Thank you so much for any help.

My environment

Icinga2: 2.8.2
Director: 1.8.0

OS: CentOS 7

The commands are imported conf files (= external commands).