about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-03-06 19:27:26 -0800
committerFranck Cuny <franck@fcuny.net>2022-03-06 19:27:26 -0800
commitdcd30c5224122343c42ecad12322f415e6f728b3 (patch)
tree32d14382d95c58bc0d7c13b20050975aca721413
parentunifi: set the correct name for the poller's unit (diff)
downloadworld-dcd30c5224122343c42ecad12322f415e6f728b3.tar.gz
prometheus: scrape from unifi-poller
-rw-r--r--hosts/common/server/prometheus.nix71
1 files changed, 40 insertions, 31 deletions
diff --git a/hosts/common/server/prometheus.nix b/hosts/common/server/prometheus.nix
index 69abec3..6c6af80 100644
--- a/hosts/common/server/prometheus.nix
+++ b/hosts/common/server/prometheus.nix
@@ -1,6 +1,30 @@
 { config, pkgs, lib, ... }:
 
-{
+let
+  relabelConfigs = [
+    {
+      source_labels = [ "__address__" ];
+      target_label = "instance";
+      replacement = "nas";
+      action = "replace";
+      regex = "192.168.6.10:(.*)";
+    }
+    {
+      source_labels = [ "__address__" ];
+      target_label = "instance";
+      replacement = "rtr";
+      action = "replace";
+      regex = "192.168.6.1:(.*)";
+    }
+    {
+      source_labels = [ "__address__" ];
+      target_label = "instance";
+      replacement = "tahoe";
+      action = "replace";
+      regex = "192.168.6.20:(.*)";
+    }
+  ];
+in {
   services.prometheus = {
     enable = true;
 
@@ -12,35 +36,20 @@
       "--web.enable-admin-api"
     ];
 
-    scrapeConfigs = [{
-      job_name = "node";
-      static_configs = [{
-        targets =
-          [ "192.168.6.1:9100" "192.168.6.10:9100" "192.168.6.20:9100" ];
-      }];
-      relabel_configs = [
-        {
-          source_labels = [ "__address__" ];
-          target_label = "instance";
-          replacement = "nas";
-          action = "replace";
-          regex = "192.168.6.10:(.*)";
-        }
-        {
-          source_labels = [ "__address__" ];
-          target_label = "instance";
-          replacement = "rtr";
-          action = "replace";
-          regex = "192.168.6.1:(.*)";
-        }
-        {
-          source_labels = [ "__address__" ];
-          target_label = "instance";
-          replacement = "tahoe";
-          action = "replace";
-          regex = "192.168.6.20:(.*)";
-        }
-      ];
-    }];
+    scrapeConfigs = [
+      {
+        job_name = "node";
+        static_configs = [{
+          targets =
+            [ "192.168.6.1:9100" "192.168.6.10:9100" "192.168.6.20:9100" ];
+        }];
+        relabel_configs = relabelConfigs;
+      }
+      {
+        job_name = "unifi-poller";
+        static_configs = [{ targets = [ "192.168.6.107:9130" ]; }];
+        relabel_configs = relabelConfigs;
+      }
+    ];
   };
 }