about summary refs log tree commit diff
path: root/modules/nixos/monitoring
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/nixos/monitoring/default.nix156
1 files changed, 83 insertions, 73 deletions
diff --git a/modules/nixos/monitoring/default.nix b/modules/nixos/monitoring/default.nix
index 5aed215..6e5b782 100644
--- a/modules/nixos/monitoring/default.nix
+++ b/modules/nixos/monitoring/default.nix
@@ -4,9 +4,11 @@
   pkgs,
   ...
 }:
-with lib; let
+with lib;
+let
   cfg = config.nixfiles.modules.monitoring;
-in {
+in
+{
   options.nixfiles.modules.monitoring.enable = mkEnableOption ''
     a glue to provision a monitoring stack
   '';
@@ -134,83 +136,93 @@ in {
       };
 
       prometheus = {
-        scrapeConfigs = with my.configurations;
+        scrapeConfigs =
+          with my.configurations;
           mapAttrsToList
-          (
-            name: value: {
+            (name: value: {
               job_name = name;
               static_configs = [
                 {
-                  targets = with value;
-                    map (host:
+                  targets =
+                    with value;
+                    map (
+                      host:
                       concatStringsSep ":" [
-                        (
-                          if isAttrs host
-                          then host.hostname
-                          else host
-                        )
+                        (if isAttrs host then host.hostname else host)
                         (toString port)
-                      ])
-                    hosts;
+                      ]
+                    ) hosts;
                 }
               ];
-              relabel_configs =
-                [
-                  {
-                    source_labels = ["__address__"];
-                    regex = "([^:]+):\\d+";
-                    target_label = "instance";
-                  }
-                ]
-                ++ optionals (hasAttr "relabel" value) value.relabel;
-            }
-          )
-          {
-            promtail = {
-              hosts = [manwe varda yavanna];
-              inherit (config.nixfiles.modules.promtail) port;
-            };
-            ntfy = {
-              hosts = [manwe];
-              inherit (config.nixfiles.modules.ntfy.prometheus) port;
-            };
-            soju = {
-              hosts = ["127.0.0.1"];
-              inherit (config.nixfiles.modules.soju.prometheus) port;
-            };
-            endlessh-go = {
-              hosts = [manwe varda yavanna];
-              inherit (config.services.endlessh-go.prometheus) port;
-            };
-            nginx = {
-              hosts = [manwe yavanna];
-              inherit (config.services.prometheus.exporters.nginx) port;
-            };
-            node = {
-              hosts = [manwe varda yavanna];
-              inherit (config.services.prometheus.exporters.node) port;
-            };
-            postgres = {
-              hosts = [manwe];
-              inherit (config.services.prometheus.exporters.postgres) port;
-            };
-            redis = {
-              hosts = [manwe];
-              inherit (config.services.prometheus.exporters.redis) port;
-            };
-            unbound = {
-              hosts = [manwe];
-              inherit (config.services.prometheus.exporters.unbound) port;
-            };
-            wireguard = {
-              hosts = [manwe];
-              inherit (config.services.prometheus.exporters.wireguard) port;
-            };
-            exportarr-lidarr = {
-              hosts = [yavanna];
-              inherit (config.services.prometheus.exporters.exportarr-lidarr) port;
+              relabel_configs = [
+                {
+                  source_labels = [ "__address__" ];
+                  regex = "([^:]+):\\d+";
+                  target_label = "instance";
+                }
+              ] ++ optionals (hasAttr "relabel" value) value.relabel;
+            })
+            {
+              promtail = {
+                hosts = [
+                  manwe
+                  varda
+                  yavanna
+                ];
+                inherit (config.nixfiles.modules.promtail) port;
+              };
+              ntfy = {
+                hosts = [ manwe ];
+                inherit (config.nixfiles.modules.ntfy.prometheus) port;
+              };
+              soju = {
+                hosts = [ "127.0.0.1" ];
+                inherit (config.nixfiles.modules.soju.prometheus) port;
+              };
+              endlessh-go = {
+                hosts = [
+                  manwe
+                  varda
+                  yavanna
+                ];
+                inherit (config.services.endlessh-go.prometheus) port;
+              };
+              nginx = {
+                hosts = [
+                  manwe
+                  yavanna
+                ];
+                inherit (config.services.prometheus.exporters.nginx) port;
+              };
+              node = {
+                hosts = [
+                  manwe
+                  varda
+                  yavanna
+                ];
+                inherit (config.services.prometheus.exporters.node) port;
+              };
+              postgres = {
+                hosts = [ manwe ];
+                inherit (config.services.prometheus.exporters.postgres) port;
+              };
+              redis = {
+                hosts = [ manwe ];
+                inherit (config.services.prometheus.exporters.redis) port;
+              };
+              unbound = {
+                hosts = [ manwe ];
+                inherit (config.services.prometheus.exporters.unbound) port;
+              };
+              wireguard = {
+                hosts = [ manwe ];
+                inherit (config.services.prometheus.exporters.wireguard) port;
+              };
+              exportarr-lidarr = {
+                hosts = [ yavanna ];
+                inherit (config.services.prometheus.exporters.exportarr-lidarr) port;
+              };
             };
-          };
 
         ruleFiles = [
           ./rules/nginx.yaml
@@ -222,9 +234,7 @@ in {
         alertmanagers = [
           {
             scheme = "https";
-            static_configs = [
-              {targets = [config.nixfiles.modules.alertmanager.domain];}
-            ];
+            static_configs = [ { targets = [ config.nixfiles.modules.alertmanager.domain ]; } ];
           }
         ];
       };

Consider giving Nix/NixOS a try! <3