From 85ef08283f946526fe663275a3201e114af84083 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Mon, 22 Aug 2022 12:31:34 +0200 Subject: [PATCH] Alerting: Fix links in Microsoft Teams notifications (#54003) (#54012) (cherry picked from commit c960301aa8241b3a218f359db82651c8b8b1dc20) Co-authored-by: George Robinson --- .../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 7798b2fd31c..63c661b2cbc 100644 --- a/pkg/services/ngalert/notifier/channels/default_template.go +++ b/pkg/services/ngalert/notifier/channels/default_template.go @@ -43,13 +43,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 2647a1876be..f121908329f 100644 --- a/pkg/services/ngalert/notifier/channels/default_template_test.go +++ b/pkg/services/ngalert/notifier/channels/default_template_test.go @@ -148,13 +148,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) @@ -166,9 +166,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) @@ -183,13 +183,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) @@ -201,9 +201,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) `,