diff --git a/nixos/components/monitor/default.nix b/nixos/components/monitor/default.nix index dc6bc1c..a7fe06a 100644 --- a/nixos/components/monitor/default.nix +++ b/nixos/components/monitor/default.nix @@ -11,6 +11,7 @@ with types; }; imports = [ + ./export-zfs.nix ./netdata.nix ./opentelemetry.nix ./prometheus.nix @@ -19,4 +20,5 @@ with types; ]; config = mkIf config.components.monitor.enable { }; + } diff --git a/nixos/components/monitor/export-zfs.nix b/nixos/components/monitor/export-zfs.nix new file mode 100644 index 0000000..750e0e6 --- /dev/null +++ b/nixos/components/monitor/export-zfs.nix @@ -0,0 +1,32 @@ +{ pkgs, config, lib, ... }: +with lib; +with types; +{ + options.components.monitor.exporters.zfs.enable = mkOption { + type = lib.types.bool; + default = config.components.monitor.enable; + }; + + config = mkMerge [ + (mkIf config.components.monitor.exporters.zfs.enable { + + services.telegraf.extraConfig.inputs.zfs = {}; + + services.prometheus.exporters.zfs.enable = true; + services.opentelemetry-collector.settings = { + receivers.prometheus.config.scrape_configs = [ + { + job_name = "zfs"; + scrape_interval = "10s"; + static_configs = [{ + targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.zfs.port}" ]; + }]; + } + ]; + service.pipelines.metrics.receivers = [ "prometheus" ]; + }; + + }) + ]; + +} diff --git a/nixos/machines/cream/configuration.nix b/nixos/machines/cream/configuration.nix index 8d24b81..35f7d3e 100644 --- a/nixos/machines/cream/configuration.nix +++ b/nixos/machines/cream/configuration.nix @@ -39,6 +39,7 @@ components.monitor.enable = true; components.monitor.opentelemetry.exporter.endpoint = "10.100.0.1:4317"; # orbi + components.monitor.exporters.zfs.enable = false; home-manager.users.mainUser.home.sessionPath = [ "$HOME/.timewarrior/scripts" ];