Shorten links to Prometheus console in alertmanager UI.

Change-Id: Id22736ba573b031bc88b95442fa04e71893a52ae
This commit is contained in:
Julius Volz 2013-08-20 16:23:33 +02:00
parent db87129fa8
commit 7c21fb1f5a
3 changed files with 21 additions and 8 deletions

View File

@ -160,6 +160,11 @@ func writeEmailBody(w io.Writer, event *Event) error {
if err := bodyTmpl.Execute(w, event); err != nil {
return err
}
buf := &bytes.Buffer{}
if err := bodyTmpl.Execute(buf, event); err != nil {
return err
}
log.Println(buf.String())
return nil
}

View File

@ -19,10 +19,6 @@ import (
"time"
)
func timeSince(t time.Time) string {
return time.Now().Round(time.Second / 10).Sub(t.Round(time.Second / 10)).String()
}
// By Russ Cox, https://groups.google.com/d/msg/golang-nuts/OEdSDgEC7js/iyhU9DW_IKcJ.
func eq(args ...interface{}) bool {
if len(args) == 0 {
@ -47,7 +43,19 @@ func eq(args ...interface{}) bool {
return false
}
var webHelpers = template.FuncMap{
"timeSince": timeSince,
"eq": eq,
func timeSince(t time.Time) string {
return time.Now().Round(time.Second / 10).Sub(t.Round(time.Second / 10)).String()
}
func truncate(str string, n int) string {
if len(str) <= n {
return str
}
return str[:n] + "..."
}
var webHelpers = template.FuncMap{
"eq": eq,
"timeSince": timeSince,
"truncate": truncate,
}

View File

@ -46,7 +46,7 @@
</td>
<td>{{timeSince .Created}} ago</td>
<td>{{timeSince .LastRefreshed}} ago</td>
<td><a href="{{.Event.Payload.GeneratorUrl}}">{{.Event.Payload.GeneratorUrl}}</a></td>
<td><a href="{{.Event.Payload.GeneratorUrl}}">{{(truncate .Event.Payload.GeneratorUrl 40)}}</a></td>
<td>{{.Event.Payload.AlertingRule}}</td>
<td>
{{$silence := call $silenceForEvent .Event}}