From 0396c2bb3334ae79482224cab2ee8de053414a48 Mon Sep 17 00:00:00 2001 From: Marie Roque Date: Fri, 22 Sep 2023 11:34:23 +0200 Subject: [PATCH] Fix notification-template --- files/templates/alertmanager/notification-template.tmpl | 2 +- .../test/notification-template/case-1-awsconfig.golden | 2 +- .../test/notification-template/case-2-azureconfig.golden | 2 +- .../test/notification-template/case-3-kvmconfig.golden | 2 +- .../test/notification-template/case-4-control-plane.golden | 2 +- .../notification-template/case-5-cluster-api-v1alpha3.golden | 2 +- .../test/notification-template/case-6-cluster-api-eks.golden | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/files/templates/alertmanager/notification-template.tmpl b/files/templates/alertmanager/notification-template.tmpl index 29a868a0e..539857ce6 100644 --- a/files/templates/alertmanager/notification-template.tmpl +++ b/files/templates/alertmanager/notification-template.tmpl @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}[[ .GrafanaAddress ]]/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}[[ .GrafanaAddress ]]/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-1-awsconfig.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-1-awsconfig.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-1-awsconfig.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-1-awsconfig.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-2-azureconfig.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-2-azureconfig.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-2-azureconfig.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-2-azureconfig.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-3-kvmconfig.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-3-kvmconfig.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-3-kvmconfig.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-3-kvmconfig.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-4-control-plane.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-4-control-plane.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-4-control-plane.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-4-control-plane.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-5-cluster-api-v1alpha3.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-5-cluster-api-v1alpha3.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-5-cluster-api-v1alpha3.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-5-cluster-api-v1alpha3.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }} diff --git a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-6-cluster-api-eks.golden b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-6-cluster-api-eks.golden index 7e8e54c13..57a0b4917 100644 --- a/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-6-cluster-api-eks.golden +++ b/service/controller/resource/alerting/alertmanagerconfig/test/notification-template/case-6-cluster-api-eks.golden @@ -1,6 +1,6 @@ {{ define "__alertmanager" }}Alertmanager{{ end }} {{ define "__alertmanagerurl" }}{{ .ExternalURL }}/#/alerts?receiver={{ .Receiver }}&silenced=false&inhibited=false&active=true&filter=%7Balertname%3D%22{{ .CommonLabels.alertname }}%22%7D{{ end }} -{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (index .Alerts 0).Annotations.dashboard }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} +{{ define "__dashboardurl" -}}{{ if hasPrefix "https://" (string (index .Alerts 0).Annotations.dashboard) }}{{ (index .Alerts 0).Annotations.dashboard }}{{ else }}https://grafana/d/{{ (index .Alerts 0).Annotations.dashboard }}{{ end }}{{- end }} {{ define "__runbookurl" -}}https://intranet.giantswarm.io/docs/support-and-ops/ops-recipes/{{ (index .Alerts 0).Annotations.opsrecipe }}{{- end }} {{ define "slack.default.title" }}{{ .Status | toUpper }}[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }}{{- else }}{{ .Alerts.Resolved | len }}{{- end }}] {{ (index .Alerts 0).Labels.alertname }} - Team {{ (index .Alerts 0).Labels.team }}{{ end }}