Skip to content

Commit

Permalink
update template
Browse files Browse the repository at this point in the history
  • Loading branch information
Gentleelephant committed May 13, 2024
1 parent 18e701d commit 65471ea
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions helm/templates/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ data:
{{ "{{ define \"nm.default.message.cn\" }}{{ if ne (len .Status) 0 }}[{{ .Status | translate }}] {{ end }}{{ .MessageCN }}{{ end }}" }}
{{ "{{ define \"nm.default.subject\" }}{{ if eq (len .Alerts) 1 }}{{ range .Alerts }}{{ template \"nm.default.message\" . }}{{ end }}{{ else }}{{ .Alerts | len }} {{ if ne (len .Status) 0 }}{{ .Status }} {{ end }}alerts{{ if gt (len .GroupLabels.SortedPairs) 0 }} for {{ range .GroupLabels.SortedPairs }}{{ .Name | translate }}={{ .Value }} {{ end }}{{ end }}{{ end }}{{ end }}" }}
{{ "{{ define \"nm.subject\" }}{{ $status := .Status }}{{ $numAlerts := len .Alerts }}{{ if eq $numAlerts 0 }}Show nothing{{ else if eq $numAlerts 1 }}{{ range .Alerts }}{{ $alertTitle := \"\" }}{{ $alertType := .Labels.alerttype }}{{ $alertName := .Labels.alertname }}{{ $cluster := .Labels.cluster }}{{ $node := .Labels.node }}{{ $pod := .Labels.pod }}{{ $namespace := .Labels.namespace }}{{ if eq $alertType \"metric\" }}{{ $alertTitle = \"[Metrics Alert]\" }}{{ else if eq $alertType \"auditing\" }}{{ $alertTitle = \"[Audit Alert]\" }}{{ else if eq $alertType \"event\" }}{{ $alertTitle = \"[Event Alert]\" }}{{ else }}{{ $alertTitle = \"[Unknown Alert]\" }}{{ end }}{{ $output := printf \"%s [%s]\" $alertTitle $status }}{{ if $alertName }}{{ $output = printf \"%s alertname=%s\" $output $alertName }}{{ end }}{{ if $cluster }}{{ $output = printf \"%s | cluster=%s\" $output $cluster }}{{ end }}{{ if $namespace }}{{ $output = printf \"%s | namespace=%s\" $output $namespace }}{{ end }}{{ if $pod }}{{ $output = printf \"%s | pod=%s\" $output $pod }}{{ if $node }}{{ $output = printf \"%s/node=%s\" $output $node }}{{ end }}{{ else }}{{ if $node }}{{ $output = printf \"%s | node=%s\" $output $node }}{{ end }}{{ end }}{{ $output }}{{ end }}{{ else }}{{ $alertTitle := \"[Aggregation\" }}{{ $alertType := index .GroupLabels \"alerttype\" }}{{ $alertName := index .GroupLabels \"alertname\" }}{{ $cluster := index .GroupLabels \"cluster\" }}{{ $namespace := index .GroupLabels \"namespace\" }}{{ if eq $alertType \"metric\" }}{{ $alertTitle = printf \"%s Metrics Alert]\" $alertTitle }}{{ else if eq $alertType \"auditing\" }}{{ $alertTitle = printf \"%s Audit Alert]\" $alertTitle }}{{ else if eq $alertType \"event\" }}{{ $alertTitle = printf \"%s Event Alert]\" $alertTitle }}{{ else }}{{ $alertTitle = printf \"%s Alert]\" $alertTitle }}{{ end }}{{ $output := printf \"%s [%s]\" $alertTitle $status }}{{ if $alertName }}{{ $output = printf \"%s alertname=%s\" $output $alertName }}{{ end }}{{ if $cluster }}{{ $output = printf \"%s | cluster=%s\" $output $cluster }}{{ end }}{{ if $namespace }}{{ $output = printf \"%s | namespace=%s\" $output $namespace }}{{ end }}{{ $output }}{{ end }}{{ end }}" }}
{{ "{{ define \"nm.subject\" }}{{ $raw := .Status }}{{ $status := title $raw }}{{ $numAlerts := len .Alerts }}{{ if eq $numAlerts 0 }}Show nothing{{ else if eq $numAlerts 1 }}{{ range .Alerts }}{{ $alertTitle := \"\" }}{{ $alertType := .Labels.alerttype }}{{ $alertName := .Labels.alertname }}{{ $cluster := .Labels.cluster }}{{ $node := .Labels.node }}{{ $pod := .Labels.pod }}{{ $namespace := .Labels.namespace }}{{ if eq $alertType \"metric\" }}{{ $alertTitle = \"[Metrics Alert]\" }}{{ else if eq $alertType \"auditing\" }}{{ $alertTitle = \"[Audit Alert]\" }}{{ else if eq $alertType \"event\" }}{{ $alertTitle = \"[Event Alert]\" }}{{ else }}{{ $alertTitle = \"[Unknown Alert]\" }}{{ end }}{{ $output := printf \"%s [%s]\" $alertTitle $status }}{{ if $alertName }}{{ $output = printf \"%s alertname=%s\" $output $alertName }}{{ end }}{{ if $cluster }}{{ $output = printf \"%s | cluster=%s\" $output $cluster }}{{ end }}{{ if $namespace }}{{ $output = printf \"%s | namespace=%s\" $output $namespace }}{{ end }}{{ if $pod }}{{ $output = printf \"%s | pod=%s\" $output $pod }}{{ if $node }}{{ $output = printf \"%s/node=%s\" $output $node }}{{ end }}{{ else }}{{ if $node }}{{ $output = printf \"%s | node=%s\" $output $node }}{{ end }}{{ end }}{{ $output }}{{ end }}{{ else }}{{ $alertTitle := \"[Aggregation\" }}{{ $alertType := index .GroupLabels \"alerttype\" }}{{ $alertName := index .GroupLabels \"alertname\" }}{{ $cluster := index .GroupLabels \"cluster\" }}{{ $namespace := index .GroupLabels \"namespace\" }}{{ if eq $alertType \"metric\" }}{{ $alertTitle = printf \"%s Metrics Alert]\" $alertTitle }}{{ else if eq $alertType \"auditing\" }}{{ $alertTitle = printf \"%s Audit Alert]\" $alertTitle }}{{ else if eq $alertType \"event\" }}{{ $alertTitle = printf \"%s Event Alert]\" $alertTitle }}{{ else }}{{ $alertTitle = printf \"%s Alert]\" $alertTitle }}{{ end }}{{ $output := printf \"%s [%s]\" $alertTitle $status }}{{ if $alertName }}{{ $output = printf \"%s alertname=%s\" $output $alertName }}{{ end }}{{ if $cluster }}{{ $output = printf \"%s | cluster=%s\" $output $cluster }}{{ end }}{{ if $namespace }}{{ $output = printf \"%s | namespace=%s\" $output $namespace }}{{ end }}{{ $output }}{{ end }}{{ end }}" }}
{{ "{{ define \"nm.default.text\" }}{{ range .Alerts }}{{ template \"nm.default.message\" . }}" }}
{{ "{{ range .Labels.SortedPairs }} {{ .Name | translate }}: {{ .Value }}" }}
{{ "{{ end }}{{ range .Annotations.SortedPairs.Filter \"runbook_url\" \"message\" \"summary\" \"summary_cn\" }} {{ .Name | translate }}: {{ .Value }}" }}
Expand Down

0 comments on commit 65471ea

Please sign in to comment.