From ba6f0387b26e53a7a6b61b22d4f73d246251b1ed Mon Sep 17 00:00:00 2001 From: SebastianStork Date: Tue, 10 Mar 2026 21:22:33 +0100 Subject: [PATCH] prometheus, alertmanager: Adjust alert wording depending on firing or resolved status --- modules/nixos/services/alertmanager.nix | 5 ++++- modules/nixos/services/prometheus.nix | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/nixos/services/alertmanager.nix b/modules/nixos/services/alertmanager.nix index f483fae..9a43904 100644 --- a/modules/nixos/services/alertmanager.nix +++ b/modules/nixos/services/alertmanager.nix @@ -83,7 +83,10 @@ in notification = { topic = "splitleaf"; priority = "default"; - templates.title = ''{{ index .Annotations "summary" }}''; + templates = { + title = ''{{ if eq .Status "firing" }}{{ index .Annotations "summary" }}{{ else }}{{ index .Annotations "summary_resolved" }}{{ end }}''; + description = "."; + }; tags = [ { condition = ''status == "resolved"''; diff --git a/modules/nixos/services/prometheus.nix b/modules/nixos/services/prometheus.nix index 22ee4cc..17f887d 100644 --- a/modules/nixos/services/prometheus.nix +++ b/modules/nixos/services/prometheus.nix @@ -97,7 +97,7 @@ in labels.severity = "critical"; annotations = { summary = "${hostName} is DOWN"; - description = "${hostName} has not reported any metrics for more than 2 minutes."; + summary_resolved = "${hostName} is up again"; }; }) ) @@ -108,7 +108,7 @@ in for = "2m"; annotations = { summary = "{{ $labels.job }} on {{ $labels.instance }} is DOWN"; - description = "{{ $labels.job }} on {{ $labels.instance }} has been down for more than 2 minutes."; + summary_resolved = "{{ $labels.job }} on {{ $labels.instance }} is up again"; }; } { @@ -116,7 +116,7 @@ in expr = ''comin_deployment_info{status!="done"}''; annotations = { summary = "{{ $labels.instance }} deployment failed"; - description = "The deployment of {{ $labels.instance }} with comin is failing."; + summary_resolved = "{{ $labels.instance }} deployment recovered"; }; } { @@ -125,7 +125,7 @@ in for = "10m"; annotations = { summary = "Hosts are running different commits"; - description = "Not all hosts are running the same git commit, which may indicate a failed deployment and could lead to incompatible configurations."; + summary_resolved = "All hosts are running the same commit again"; }; } ];