From 41963417dfbc9f3aa7cf9a241a85fe04e64d880f Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Sat, 10 Jan 2015 21:55:28 +0100 Subject: [PATCH] Treat `GeneratorURL` as optional in Alerts page. This fixes https://github.com/prometheus/alertmanager/issues/21 Otherwise, sending an alert with a missing `GeneratorURL` payload property would cause the template rendering to crash: Error executing template: template: alerts.html:51:76: executing "content" at <.Alert.Payload.Gener...>: invalid value; expected string --- web/templates/alerts.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/templates/alerts.html b/web/templates/alerts.html index 5f700391..18714f0d 100644 --- a/web/templates/alerts.html +++ b/web/templates/alerts.html @@ -46,7 +46,11 @@ {{timeSince .Created}} ago {{timeSince .LastRefreshed}} ago - {{(truncate .Alert.Payload.GeneratorURL 40)}} + + {{if .Alert.Payload.GeneratorURL}} + {{(truncate .Alert.Payload.GeneratorURL 40)}} + {{end}} + {{.Alert.Payload.AlertingRule}} {{$silence := call $silenceForAlert .Alert}}