Shorten links to Prometheus console in alertmanager UI.
Change-Id: Id22736ba573b031bc88b95442fa04e71893a52ae
This commit is contained in:
parent
db87129fa8
commit
7c21fb1f5a
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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}}
|
||||
|
|
Loading…
Reference in New Issue