summary refs log tree commit diff
path: root/nixos/tests/prometheus.nix
diff options
context:
space:
mode:
authorAndreas Rammhold <andreas@rammhold.de>2018-11-04 19:27:43 +0100
committerAndreas Rammhold <andreas@rammhold.de>2018-11-23 19:45:17 +0100
commit51c30821199f8b3170fdf5f54921f20a1082ad79 (patch)
tree606e4825acef101fe21db32a7b30f7c755f3e264 /nixos/tests/prometheus.nix
parentb1032db5a9a2c65737a4fb2a8410224e6b87db56 (diff)
downloadnixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar.gz
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar.bz2
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar.lz
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar.xz
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.tar.zst
nixpkgs-51c30821199f8b3170fdf5f54921f20a1082ad79.zip
nixos/prometheus: require one alertmanager configuration parameter
This commit adds an assertion that checks that either `configFile` or
`configuration` is configured for alertmanager. The alertmanager config
can not be an empty attributeset. The check executed with `amtool` fails
before the service even has the chance to start. We should probably not
allow a broken alertmanager configuration anyway.

This also introduces a test for alertmanager configuration that piggy
backs on the existing prometheus tests.
Diffstat (limited to 'nixos/tests/prometheus.nix')
-rw-r--r--nixos/tests/prometheus.nix22
1 files changed, 22 insertions, 0 deletions
diff --git a/nixos/tests/prometheus.nix b/nixos/tests/prometheus.nix
index 87a6510f40f..f1b20a33d71 100644
--- a/nixos/tests/prometheus.nix
+++ b/nixos/tests/prometheus.nix
@@ -13,6 +13,25 @@ import ./make-test.nix {
           }];
         }];
         rules = [ ''testrule = count(up{job="prometheus"})'' ];
+
+        # a very simple version of the alertmanager configuration just to see if
+        # configuration checks & service startup are working
+        alertmanager = {
+          enable = true;
+          listenAddress = "[::1]";
+          port = 9093;
+          configuration = {
+            route.receiver = "webhook";
+            receivers = [
+              {
+                name = "webhook";
+                webhook_configs = [
+                  { url = "http://localhost"; }
+                ];
+              }
+            ];
+          };
+        };
       };
     };
   };
@@ -22,5 +41,8 @@ import ./make-test.nix {
     $one->waitForUnit("prometheus.service");
     $one->waitForOpenPort(9090);
     $one->succeed("curl -s http://127.0.0.1:9090/metrics");
+    $one->waitForUnit("alertmanager.service");
+    $one->waitForOpenPort("9093");
+    $one->succeed("curl -f -s http://localhost:9093/");
   '';
 }