From c960301aa8241b3a218f359db82651c8b8b1dc20 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Mon, 22 Aug 2022 11:08:38 +0100 Subject: [PATCH] Alerting: Fix links in Microsoft Teams notifications (#54003) --- .../notifier/channels/default_template.go | 8 +++---- .../channels/default_template_test.go | 24 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pkg/services/ngalert/notifier/channels/default_template.go b/pkg/services/ngalert/notifier/channels/default_template.go index 1ff8ab5792b..6e82f622406 100644 --- a/pkg/services/ngalert/notifier/channels/default_template.go +++ b/pkg/services/ngalert/notifier/channels/default_template.go @@ -42,13 +42,13 @@ Labels: Annotations: {{ range .Annotations.SortedPairs }} - {{ .Name }} = {{ .Value }} {{ end }} -{{ if gt (len .GeneratorURL) 0 }}Source: {{ .GeneratorURL }} +{{ if gt (len .GeneratorURL) 0 }}Source: [{{ .GeneratorURL }}]({{ .GeneratorURL }}) -{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: {{ .SilenceURL }} +{{ end }}{{ if gt (len .SilenceURL) 0 }}Silence: [{{ .SilenceURL }}]({{ .SilenceURL }}) -{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: {{ .DashboardURL }} +{{ end }}{{ if gt (len .DashboardURL) 0 }}Dashboard: [{{ .DashboardURL }}]({{ .DashboardURL }}) -{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: {{ .PanelURL }} +{{ end }}{{ if gt (len .PanelURL) 0 }}Panel: [{{ .PanelURL }}]({{ .PanelURL }}) {{ end }} {{ end }}{{ end }} diff --git a/pkg/services/ngalert/notifier/channels/default_template_test.go b/pkg/services/ngalert/notifier/channels/default_template_test.go index 534eaa38648..cbec7352a09 100644 --- a/pkg/services/ngalert/notifier/channels/default_template_test.go +++ b/pkg/services/ngalert/notifier/channels/default_template_test.go @@ -147,13 +147,13 @@ Labels: Annotations: - ann1 = annv1 -Source: http://localhost/alert1 +Source: [http://localhost/alert1](http://localhost/alert1) -Silence: http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval1 +Silence: [http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval1](http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval1) -Dashboard: http://localhost/grafana/d/dbuid123 +Dashboard: [http://localhost/grafana/d/dbuid123](http://localhost/grafana/d/dbuid123) -Panel: http://localhost/grafana/d/dbuid123?viewPanel=puid123 +Panel: [http://localhost/grafana/d/dbuid123?viewPanel=puid123](http://localhost/grafana/d/dbuid123?viewPanel=puid123) @@ -165,9 +165,9 @@ Labels: Annotations: - ann1 = annv2 -Source: http://localhost/alert2 +Source: [http://localhost/alert2](http://localhost/alert2) -Silence: http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval2 +Silence: [http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval2](http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval2) @@ -182,13 +182,13 @@ Labels: Annotations: - ann1 = annv3 -Source: http://localhost/alert3 +Source: [http://localhost/alert3](http://localhost/alert3) -Silence: http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval3 +Silence: [http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval3](http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval3) -Dashboard: http://localhost/grafana/d/dbuid456 +Dashboard: [http://localhost/grafana/d/dbuid456](http://localhost/grafana/d/dbuid456) -Panel: http://localhost/grafana/d/dbuid456?viewPanel=puid456 +Panel: [http://localhost/grafana/d/dbuid456?viewPanel=puid456](http://localhost/grafana/d/dbuid456?viewPanel=puid456) @@ -200,9 +200,9 @@ Labels: Annotations: - ann1 = annv4 -Source: http://localhost/alert4 +Source: [http://localhost/alert4](http://localhost/alert4) -Silence: http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval4 +Silence: [http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval4](http://localhost/grafana/alerting/silence/new?alertmanager=grafana&matcher=alertname%3Dalert1&matcher=lbl1%3Dval4) `,