about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--hosts/common/nas.nix1
-rw-r--r--hosts/common/server/prometheus.nix29
2 files changed, 30 insertions, 0 deletions
diff --git a/hosts/common/nas.nix b/hosts/common/nas.nix
index 3f38792..8ab11a8 100644
--- a/hosts/common/nas.nix
+++ b/hosts/common/nas.nix
@@ -4,5 +4,6 @@
   imports = [
     ./server/default.nix
     ./server/samba.nix
+    ./server/prometheus.nix
   ];
 }
diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix
new file mode 100644
index 0000000..1c7c906
--- /dev/null
+++ b/hosts/common/server/prometheus.nix
@@ -0,0 +1,29 @@
+{ config, pkgs, lib, ... }:
+
+let
+  # Scrape a list of static targets for a job.
+  staticScrape = (job_name: targets: {
+    inherit job_name;
+    static_configs = [{ inherit targets; }];
+  });
+in
+{
+  services.prometheus = {
+    enable = true;
+
+    globalConfig.scrape_interval = "15s";
+
+    extraFlags = [
+      # 3 years of retention
+      "--storage.tsdb.retention=1095d"
+      "--web.enable-admin-api"
+    ];
+
+    scrapeConfigs = [
+      (staticScrape "node" [
+        "rtr:9100"
+        "tahoe:9100"
+      ])
+    ];
+  };
+}