From 433966c4332399bc0cb3c9286f36bdc9af4a1e29 Mon Sep 17 00:00:00 2001
From: Dmitriy Pleshevskiy <dmitriy@pleshevski.ru>
Date: Thu, 30 Jan 2025 01:26:56 +0300
Subject: [PATCH] host/istal: add node_exporter to prometheus

---
 hosts/istal/services/default.nix    |  1 +
 hosts/istal/services/prometheus.nix | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 hosts/istal/services/prometheus.nix

diff --git a/hosts/istal/services/default.nix b/hosts/istal/services/default.nix
index 0823c77..e177868 100644
--- a/hosts/istal/services/default.nix
+++ b/hosts/istal/services/default.nix
@@ -5,5 +5,6 @@
     # ./docker-registry-proxy.nix
     ./nginx.nix
     ./renovate.nix
+    ./prometheus.nix
   ];
 }
diff --git a/hosts/istal/services/prometheus.nix b/hosts/istal/services/prometheus.nix
new file mode 100644
index 0000000..ad19ba3
--- /dev/null
+++ b/hosts/istal/services/prometheus.nix
@@ -0,0 +1,17 @@
+{ config, ... }:
+
+{
+  services.prometheus.exporters.node = {
+    enable = true;
+    port = 40000;
+    # https://github.com/NixOS/nixpkgs/blob/nixos-24.05/nixos/modules/services/monitoring/prometheus/exporters.nix
+    enabledCollectors = [ "systemd" ];
+    # /nix/store/zgsw0yx18v10xa58psanfabmg95nl2bb-node_exporter-1.8.1/bin/node_exporter  --help
+    extraFlags = [ "--collector.ethtool" "--collector.softirqs" "--collector.tcpstat" "--collector.wifi" ];
+  };
+
+  networking.firewall.allowedTCPPorts = [
+    config.services.prometheus.exporters.node.port
+  ];
+
+}