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
This commit is contained in:
Julius Volz 2015-01-10 21:55:28 +01:00
parent d2ce4fa3e7
commit 41963417df
1 changed files with 5 additions and 1 deletions

View File

@ -46,7 +46,11 @@
</td> </td>
<td>{{timeSince .Created}} ago</td> <td>{{timeSince .Created}} ago</td>
<td>{{timeSince .LastRefreshed}} ago</td> <td>{{timeSince .LastRefreshed}} ago</td>
<td><a href="{{.Alert.Payload.GeneratorURL}}">{{(truncate .Alert.Payload.GeneratorURL 40)}}</a></td> <td>
{{if .Alert.Payload.GeneratorURL}}
<a href="{{.Alert.Payload.GeneratorURL}}">{{(truncate .Alert.Payload.GeneratorURL 40)}}</a>
{{end}}
</td>
<td>{{.Alert.Payload.AlertingRule}}</td> <td>{{.Alert.Payload.AlertingRule}}</td>
<td> <td>
{{$silence := call $silenceForAlert .Alert}} {{$silence := call $silenceForAlert .Alert}}