@@ -46,7 +46,7 @@ type discordOut struct {
46
46
func main () {
47
47
whURL := flag .String ("webhook.url" , "https://blah" , "" )
48
48
flag .Parse ()
49
- http .ListenAndServe (":8080 " , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
49
+ http .ListenAndServe ("localhost:9094 " , http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
50
50
b , err := ioutil .ReadAll (r .Body )
51
51
if err != nil {
52
52
panic (err )
@@ -64,18 +64,18 @@ func main() {
64
64
65
65
Content := "!!"
66
66
if amo .CommonAnnotations .Summary != "" {
67
- Content = fmt .Sprintf (" === %s === \n " , amo .CommonAnnotations .Summary )
67
+ Content = fmt .Sprintf (" === %s === \n ``` " , amo .CommonAnnotations .Summary )
68
68
}
69
69
70
70
for _ , alert := range amo .Alerts {
71
71
realname := alert .Labels ["instance" ]
72
72
if strings .Contains (realname , "localhost" ) && alert .Labels ["exported_instance" ] != "" {
73
73
realname = alert .Labels ["exported_instance" ]
74
74
}
75
- Content += fmt .Sprintf ("FIRING : %s on %s\n " , alert .Labels ["alertname" ], realname )
75
+ Content += fmt .Sprintf ("[%s] : %s on %s\n %s \n " , strings . ToUpper ( amo . Status ), alert .Labels ["alertname" ], realname , alert . Annotations . Description )
76
76
}
77
77
78
- DO .Content = Content
78
+ DO .Content = Content + "```"
79
79
80
80
DOD , _ := json .Marshal (DO )
81
81
http .Post (* whURL , "application/json" , bytes .NewReader (DOD ))
0 commit comments