diff --git a/hosts/idols-aquamarine/monitoring/alert.nix b/hosts/idols-aquamarine/monitoring/alert.nix
index 8983e17e..d5ff69ff 100644
--- a/hosts/idols-aquamarine/monitoring/alert.nix
+++ b/hosts/idols-aquamarine/monitoring/alert.nix
@@ -126,6 +126,13 @@
# Message template
# Telegram limits a message to 4096 chars, so only render the first 5 alerts
# in a group and keep the fields minimal (no full label dump).
+ #
+ # WARNING: never use template variables ($i, $a, ...) here. The NixOS
+ # alertmanager module pipes the generated config through `envsubst`
+ # (to inject $TELEGRAM_BOT_TOKEN etc.), which silently replaces any
+ # $var in this template with an empty string and breaks rendering at
+ # notify time. Use `{{ range .Alerts }}` + dot, and `define`/`template`
+ # for reuse instead.
message = ''
{{- if eq .Status "firing" }}
π‘ εθ¦θ§¦ε [{{ .CommonLabels.severity | title }}] {{ .CommonLabels.alertname }} (ε
± {{ len .Alerts }} ζ‘)
@@ -137,18 +144,21 @@
β’ Cluster: {{ with .CommonLabels.cluster }}{{ . }}{{ else }}N/A{{ end }}
β’ Env: {{ with .CommonLabels.env }}{{ . }}{{ else }}N/A{{ end }}
β’ Namespace: {{ with .CommonLabels.namespace }}{{ . }}{{ else }}N/A{{ end }}
- {{- range $i, $a := .Alerts }}
- {{- if lt $i 5 }}
+ {{- define "alert" }}
ββββββββ
- π {{ with $a.Annotations.summary }}{{ . }}{{ else }}{{ $a.Labels.instance }}{{ end }}
- {{- with $a.Labels.nodename }}
+ π {{ with .Annotations.summary }}{{ . }}{{ else }}{{ .Labels.instance }}{{ end }}
+ {{- with .Labels.nodename }}
π {{ . }}
{{- end }}
- π Grafana Explore Β· β± {{ $a.StartsAt.Format "2006-01-02 15:04:05" }}
+ π Grafana Explore Β· β± {{ .StartsAt.Format "2006-01-02 15:04:05" }}
{{- end }}
+ {{- if le (len .Alerts) 5 }}
+ {{- range .Alerts }}{{ template "alert" . }}
+ {{- end }}
+ {{- else }}
+ {{- range slice .Alerts 0 5 }}{{ template "alert" . }}
{{- end }}
- {{- if gt (len .Alerts) 5 }}
β οΈ ε¦ζ {{ len (slice .Alerts 5) }} ζ‘εη»εθ¦ζͺεεΊοΌθ―·ζ₯η Alertmanagerγ
{{- end }}