diff --git a/sp-modules/monitoring/config-paths-needed.json b/sp-modules/monitoring/config-paths-needed.json new file mode 100644 index 0000000..91fb203 --- /dev/null +++ b/sp-modules/monitoring/config-paths-needed.json @@ -0,0 +1,3 @@ +[ + [ "selfprivacy", "modules", "monitoring" ] +] diff --git a/sp-modules/monitoring/flake.nix b/sp-modules/monitoring/flake.nix new file mode 100644 index 0000000..b6b3f77 --- /dev/null +++ b/sp-modules/monitoring/flake.nix @@ -0,0 +1,9 @@ +{ + description = "PoC SP module for Prometheus-based monitoring"; + + outputs = { self }: { + nixosModules.default = import ./module.nix; + configPathsNeeded = + builtins.fromJSON (builtins.readFile ./config-paths-needed.json); + }; +} diff --git a/sp-modules/monitoring/module.nix b/sp-modules/monitoring/module.nix new file mode 100644 index 0000000..90bf806 --- /dev/null +++ b/sp-modules/monitoring/module.nix @@ -0,0 +1,33 @@ +{config, lib, ...}: let + cfg = config.selfprivacy.modules.monitoring; +in { + options.selfprivacy.modules.monitoring = { + enable = lib.mkOption { + default = false; + type = lib.types.bool; + }; + }; + config = lib.mkIf cfg.enable { + services.prometheus = { + enable = true; + port = 9001; + listenAddress = "127.0.0.1"; + exporters = { + node = { + enable = true; + enabledCollectors = [ "systemd" ]; + port = 9002; + listenAddress = "127.0.0.1"; + }; + }; + scrapeConfigs = [ + { + job_name = "node-exporter"; + static_configs = [{ + targets = [ "127.0.0.1:9002" ]; + }]; + } + ]; + }; + }; +} \ No newline at end of file