Skip to content

Commit 5da0dc9

Browse files
committed
Nicer formatting
1 parent a33608f commit 5da0dc9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type discordOut struct {
4646
func main() {
4747
whURL := flag.String("webhook.url", "https://blah", "")
4848
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) {
5050
b, err := ioutil.ReadAll(r.Body)
5151
if err != nil {
5252
panic(err)
@@ -64,18 +64,18 @@ func main() {
6464

6565
Content := "!!"
6666
if amo.CommonAnnotations.Summary != "" {
67-
Content = fmt.Sprintf(" === %s === \n", amo.CommonAnnotations.Summary)
67+
Content = fmt.Sprintf(" === %s === \n```", amo.CommonAnnotations.Summary)
6868
}
6969

7070
for _, alert := range amo.Alerts {
7171
realname := alert.Labels["instance"]
7272
if strings.Contains(realname, "localhost") && alert.Labels["exported_instance"] != "" {
7373
realname = alert.Labels["exported_instance"]
7474
}
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)
7676
}
7777

78-
DO.Content = Content
78+
DO.Content = Content + "```"
7979

8080
DOD, _ := json.Marshal(DO)
8181
http.Post(*whURL, "application/json", bytes.NewReader(DOD))

0 commit comments

Comments
 (0)