diff --git a/hosts/idols-aquamarine/monitoring/alert.nix b/hosts/idols-aquamarine/monitoring/alert.nix index c046c158..8983e17e 100644 --- a/hosts/idols-aquamarine/monitoring/alert.nix +++ b/hosts/idols-aquamarine/monitoring/alert.nix @@ -128,25 +128,24 @@ # in a group and keep the fields minimal (no full label dump). message = '' {{- if eq .Status "firing" }} - 🟡 告警触发 {{ .CommonLabels.alertname }} [{{ index .CommonLabels "severity" | title }}] (共 {{ len .Alerts }} 条) + 🟡 告警触发 [{{ .CommonLabels.severity | title }}] {{ .CommonLabels.alertname }} (共 {{ len .Alerts }} 条) {{- else }} - 🟢 告警恢复 {{ .CommonLabels.alertname }} [{{ index .CommonLabels "severity" | title }}] + 🟢 告警恢复 [{{ .CommonLabels.severity | title }}] {{ .CommonLabels.alertname }} {{- end }} + • 告警组: {{ .CommonLabels.alertgroup }} + • 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 }} - 📊 详情: - • 告警组: {{ $a.Labels.alertgroup }} - • 等级: {{ if eq $a.Labels.severity "critical" }}🔴{{ else }}🟡 {{ end }} {{ $a.Labels.severity | title }} - • 实例: {{ with $a.Labels.instance }}{{ . }}{{ else }}N/A{{ end }} - • Pod: {{ with $a.Labels.pod }}{{ . }}{{ else }}N/A{{ end }} - • 查询: Grafana Explore - • 触发值: {{ with $a.Annotations.value }}{{ . }}{{ else }}N/A{{ end }} - • Env: {{ with $a.Labels.env }}{{ . }}{{ else }}N/A{{ end }} - • Cluster: {{ with $a.Labels.cluster }}{{ . }}{{ else }}N/A{{ end }} - • Namespace: {{ with $a.Labels.namespace }}{{ . }}{{ else }}N/A{{ end }} - • 触发时间: {{ $a.StartsAt.Format "2006-01-02 15:04:05" }} + ━━━━━━━━ + 📌 {{ with $a.Annotations.summary }}{{ . }}{{ else }}{{ $a.Labels.instance }}{{ end }} + {{- with $a.Labels.nodename }} + 🏠 {{ . }} + {{- end }} + 🔗 Grafana Explore · ⏱ {{ $a.StartsAt.Format "2006-01-02 15:04:05" }} {{- end }} {{- end }} {{- if gt (len .Alerts) 5 }}