about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring
diff options
context:
space:
mode:
authorThomas Gerbet <thomas@gerbet.me>2021-08-30 16:54:32 +0200
committerThomas Gerbet <thomas@gerbet.me>2021-08-30 16:54:32 +0200
commit36c179b2086e34a3af86e46624a2d89de545d6b5 (patch)
tree8ad1a4ab9af017ba40ea874426e73abf26fb0b2a /nixos/modules/services/monitoring
parentd874a520155a73111f227744672254de0624aae5 (diff)
downloadnixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar.gz
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar.bz2
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar.lz
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar.xz
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.tar.zst
nixlib-36c179b2086e34a3af86e46624a2d89de545d6b5.zip
nixos/unifi-poller: add support of Loki
Since the v2.0.2 unifi-poller supports Loki [0][1], this contribution
adds the options so it can be used.

[0] https://github.com/unpoller/unpoller/releases/tag/v2.0.2-beta1
[1] https://unpoller.com/docs/dependencies/loki/
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r--nixos/modules/services/monitoring/unifi-poller.nix80
1 files changed, 78 insertions, 2 deletions
diff --git a/nixos/modules/services/monitoring/unifi-poller.nix b/nixos/modules/services/monitoring/unifi-poller.nix
index 208f5e4875b4..5b2c038ac2f5 100644
--- a/nixos/modules/services/monitoring/unifi-poller.nix
+++ b/nixos/modules/services/monitoring/unifi-poller.nix
@@ -6,7 +6,7 @@ let
   cfg = config.services.unifi-poller;
 
   configFile = pkgs.writeText "unifi-poller.json" (generators.toJSON {} {
-    inherit (cfg) poller influxdb prometheus unifi;
+    inherit (cfg) poller influxdb loki prometheus unifi;
   });
 
 in {
@@ -118,6 +118,61 @@ in {
       };
     };
 
+    loki = {
+      url = mkOption {
+        type = types.str;
+        default = "";
+        description = ''
+          URL of the Loki host.
+        '';
+      };
+      user = mkOption {
+        type = types.str;
+        default = "";
+        description = ''
+          Username for Loki.
+        '';
+      };
+      pass = mkOption {
+        type = types.path;
+        default = pkgs.writeText "unifi-poller-loki-default.password" "";
+        defaultText = "unifi-poller-influxdb-default.password";
+        description = ''
+          Path of a file containing the password for Loki.
+          This file needs to be readable by the unifi-poller user.
+        '';
+        apply = v: "file://${v}";
+      };
+      verify_ssl = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Verify Loki's certificate.
+        '';
+      };
+      tenant_id = mkOption {
+        type = types.str;
+        default = "";
+        description = ''
+          Tenant ID to use in Loki.
+        '';
+      };
+      interval = mkOption {
+        type = types.str;
+        default = "2m";
+        description = ''
+          How often the events are polled and pushed to Loki.
+        '';
+      };
+      timeout = mkOption {
+        type = types.str;
+        default = "10s";
+        description = ''
+          Should be increased in case of timeout errors.
+        '';
+      };
+    };
+
     unifi = let
       controllerOptions = {
         user = mkOption {
@@ -157,7 +212,28 @@ in {
           type = types.bool;
           default = false;
           description = ''
-            Collect and save data from the intrusion detection system to influxdb.
+            Collect and save data from the intrusion detection system to influxdb and Loki.
+          '';
+        };
+        save_events = mkOption {
+          type = types.bool;
+          default = false;
+          description = ''
+            Collect and save data from UniFi events to influxdb and Loki.
+          '';
+        };
+        save_alarms = mkOption {
+          type = types.bool;
+          default = false;
+          description = ''
+            Collect and save data from UniFi alarms to influxdb and Loki.
+          '';
+        };
+        save_anomalies = mkOption {
+          type = types.bool;
+          default = false;
+          description = ''
+            Collect and save data from UniFi anomalies to influxdb and Loki.
           '';
         };
         save_dpi = mkOption {