From 17cf6b56b936e98fec1e2ab73adadb76249385dc Mon Sep 17 00:00:00 2001 From: Wittano Bonarotti Date: Sun, 8 Dec 2024 02:20:29 +0100 Subject: [PATCH] feat(win10): added windows_exporter to prometheus --- nixos/services/prometheus.nix | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/nixos/services/prometheus.nix b/nixos/services/prometheus.nix index 11d3f8bb..e8fa7622 100644 --- a/nixos/services/prometheus.nix +++ b/nixos/services/prometheus.nix @@ -1,20 +1,32 @@ { config, lib, ... }: with lib; with lib.my; +let + windowsExporterConfig = attrsets.optionalAttrs config.hardware.virtualization.wittano.enableWindowsVM + { + job_name = "windows_exporter"; + static_configs = [{ + targets = [ "192.168.122.110:9182" ]; + }]; + }; +in { options.services.prometheus.wittano.enable = mkEnableOption "prometheus service"; config = mkIf config.services.prometheus.wittano.enable { networking.firewall.interfaces.eno1.allowedTCPPorts = [ 9090 9100 ]; - services.prometheus = { + services.prometheus = rec { enable = true; port = 9090; - scrapeConfigs = [{ - job_name = "node"; - static_configs = [{ targets = [ "localhost:9100" ]; }]; - }]; + scrapeConfigs = [ + { + job_name = "node"; + static_configs = [{ targets = [ "localhost:${builtins.toString exporters.node.port}" ]; }]; + } + windowsExporterConfig + ]; exporters.node = { enable = true;