From a5234a2a84e7db3dabb9240938ec604298ce81de Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Thu, 16 May 2024 10:57:57 +0200 Subject: [PATCH] some improvements --- nixos/components/monitor/default.nix | 2 ++ nixos/components/monitor/export-zfs.nix | 32 +++++++++++++++++++++++++ nixos/machines/cream/configuration.nix | 1 + 3 files changed, 35 insertions(+) create mode 100644 nixos/components/monitor/export-zfs.nix 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" ];