summary refs log tree commit diff
path: root/nixos/tests/prometheus.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixos/tests/prometheus.nix')
-rw-r--r--nixos/tests/prometheus.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/nixos/tests/prometheus.nix b/nixos/tests/prometheus.nix
new file mode 100644
index 000000000000..7605227100d2
--- /dev/null
+++ b/nixos/tests/prometheus.nix
@@ -0,0 +1,29 @@
+import ./make-test.nix {
+  name = "prometheus";
+
+  nodes = {
+    one = { config, pkgs, ... }: {
+      services.prometheus = {
+        enable = true;
+        globalConfig = {
+          labels = { foo = "bar"; };
+        };
+        scrapeConfigs = [{
+          job_name = "prometheus";
+          target_groups = [{
+            targets = [ "127.0.0.1:9090" ];
+            labels = { instance = "localhost"; };
+          }];
+        }];
+        rules = [ ''testrule = count(up{job="prometheus"})'' ];
+      };
+    };
+  };
+
+  testScript = ''
+    startAll;
+    $one->waitForUnit("prometheus.service");
+    $one->waitForOpenPort(9090);
+    $one->succeed("curl -s http://127.0.0.1:9090/metrics");
+  '';
+}