diff --git a/hosts/12kingdoms-youko/homelab-services/monitoring/alert.nix b/hosts/12kingdoms-youko/homelab-services/monitoring/alert.nix
index fa2c49c4..912ed747 100644
--- a/hosts/12kingdoms-youko/homelab-services/monitoring/alert.nix
+++ b/hosts/12kingdoms-youko/homelab-services/monitoring/alert.nix
@@ -27,8 +27,10 @@
# https://docs.victoriametrics.com/victoriametrics/vmalert/#link-to-alert-source
# Set this two args to generate the correct `.GeneratorURL`
"external.url" = "https://grafana.writefor.fun";
+ # Grafana resolves this by UID, then by name; it must match the provisioned
+ # datasource name in grafana/datasources.nix.
"external.alert.source" =
- ''explore?left={"datasource":"{{ if eq .Type \"vlogs\" }}VictoriaLogs{{ else }}VictoriaMetrics{{ end }}","queries":[{"expr":{{ .Expr|jsonEscape|queryEscape }},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'';
+ ''explore?left={"datasource":"victoriametrics-homelab","queries":[{"expr":{{ .Expr|jsonEscape|queryEscape }},"refId":"A"}],"range":{"from":"{{ .ActiveAt.UnixMilli }}","to":"now"}}'';
};
};
@@ -141,7 +143,7 @@
🟢 告警恢复 [{{ .CommonLabels.severity | title }}] {{ .CommonLabels.alertname }}
{{- end }}
- • 告警组: {{ .CommonLabels.alertgroup }}
+ • 告警组: {{ with .CommonLabels.alertgroup }}{{ . }}{{ else }}N/A{{ end }}
• Cluster: {{ with .CommonLabels.cluster }}{{ . }}{{ else }}N/A{{ end }}
• Env: {{ with .CommonLabels.env }}{{ . }}{{ else }}N/A{{ end }}
• Namespace: {{ with .CommonLabels.namespace }}{{ . }}{{ else }}N/A{{ end }}