{{- /* Resolved alerts (if any) */ -}}
{{- if gt (len .Alerts.Resolved) 1 -}}
{{ len .Alerts.Resolved }} logins resolved on {{ with .CommonLabels.cluster }}{{ . }}{{ else }}unknown host{{ end }}:
{{- range .Alerts.Resolved }}
• {{ with .Labels.username }}{{ . }}{{ else }}unknown{{ end }} — Source: {{ with .Labels.source }}{{ . }}{{ else }}?{{ end }}{{ with .Labels.method }}, Method: {{ . }}{{ else }}, Method: ?{{ end }}
{{- end }}
{{- else if eq (len .Alerts.Resolved) 1 -}}
{{ $a := index .Alerts.Resolved 0 -}}
Resolved login: {{ with $a.Labels.username }}{{ . }}{{ else }}unknown{{ end }} on {{ $a.Labels.cluster }}
Source: {{ with $a.Labels.source }}{{ . }}{{ else }}?{{ end }}{{ with $a.Labels.method }}, Method: {{ . }}{{ else }}, Method: ?{{ end }}
{{- end -}}
{{- /* Firing alerts (original logic) */ -}}
{{ if gt (len .Alerts.Firing) 1 -}}
{{ len .Alerts.Firing }} logins on {{ with .CommonLabels.cluster }}{{ . }}{{ else }}unknown host{{ end }}:
{{- range .Alerts.Firing }}
• {{ with .Labels.username }}{{ . }}{{ else }}unknown{{ end }} — Source: {{ with .Labels.source }}{{ . }}{{ else }}?{{ end }}{{ with .Labels.method }}, Method: {{ . }}{{ else }}, Method: ?{{ end }}
{{- end }}
{{ else if eq (len .Alerts.Firing) 1 -}}
{{ $a := index .Alerts.Firing 0 -}}
Login: {{ with $a.Labels.username }}{{ . }}{{ else }}unknown{{ end }} on {{ $a.Labels.cluster }}
Source: {{ with $a.Labels.source }}{{ . }}{{ else }}?{{ end }}{{ with $a.Labels.method }}, Method: {{ . }}{{ else }}, Method: ?{{ end }}
{{ else -}}
{{- /* If there were resolved alerts above this will still show when no firing alerts exist. */ -}}
{{ if eq (len .Alerts.Resolved) 0 -}}
Login detected — details unavailable.
{{ end -}}
{{ end -}}