From fa62983e2c4536b6e8b792bb531d8137461b30d6 Mon Sep 17 00:00:00 2001
From: Ingolf Wagner <contact@ingolf-wagner.de>
Date: Wed, 26 Feb 2025 14:57:23 +0700
Subject: [PATCH] :arrow_up: use new nixos-telemetry architecture

---
 components/monitor/container.nix          | 2 +-
 flake.lock                                | 6 +++---
 flake.nix                                 | 6 ------
 machines/cherry/configuration.nix         | 2 +-
 machines/chungus/configuration.nix        | 2 +-
 machines/chungus/telemetry/prometheus.nix | 8 ++------
 machines/orbi/configuration.nix           | 4 ++--
 7 files changed, 10 insertions(+), 20 deletions(-)

diff --git a/components/monitor/container.nix b/components/monitor/container.nix
index e724c16..86a38db 100644
--- a/components/monitor/container.nix
+++ b/components/monitor/container.nix
@@ -14,7 +14,7 @@ with types;
   config = {
     telemetry.enable = mkDefault true;
     telemetry.metrics.enable = mkDefault false;
-    telemetry.opentelemetry.enable = false;
+    telemetry.apps.opentelemetry.enable = false;
     services.journald.extraConfig = "SystemMaxUse=1G";
   };
 
diff --git a/flake.lock b/flake.lock
index 659b37d..8043856 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1405,11 +1405,11 @@
         "treefmt-nix": "treefmt-nix_8"
       },
       "locked": {
-        "lastModified": 1740492270,
-        "narHash": "sha256-4JGmOis851TM0OL88S7+u8HbNk25xvBNh4dVsNDRAC8=",
+        "lastModified": 1740556259,
+        "narHash": "sha256-k8f7+Ir+DiK7rVH1RoHt8Do/Y8JKagTlNoSwgOPVsU0=",
         "owner": "mrvandalo",
         "repo": "nixos-telemetry",
-        "rev": "94c12227bd7e98f7ec8f8759d41941c5afcce352",
+        "rev": "3481a8b1c94fc5adc4ae7c1ba9695e6fe59389de",
         "type": "github"
       },
       "original": {
diff --git a/flake.nix b/flake.nix
index 9d7d3b3..28f37a3 100644
--- a/flake.nix
+++ b/flake.nix
@@ -289,12 +289,6 @@
         ./features
         ./modules # todo : spread this across features and components
         #./system/all # todo : spread this across features and components
-        (
-          { lib, pkgs, ... }:
-          {
-            telemetry.netdata.enable = false;
-          }
-        )
 
         # some modules I always use
         telemetry.nixosModules.telemetry
diff --git a/machines/cherry/configuration.nix b/machines/cherry/configuration.nix
index 5dba8f9..c75bdf0 100644
--- a/machines/cherry/configuration.nix
+++ b/machines/cherry/configuration.nix
@@ -63,7 +63,7 @@
   components.terminal.enable = true;
 
   telemetry.enable = true;
-  telemetry.opentelemetry.exporter.endpoint = "10.100.0.1:4317"; # orbi
+  telemetry.apps.opentelemetry.exporter.endpoint = "10.100.0.1:4317"; # orbi
 
   home-manager.users.mainUser.home.sessionPath = [ "$HOME/.timewarrior/scripts" ];
   # todo: move to homemanager
diff --git a/machines/chungus/configuration.nix b/machines/chungus/configuration.nix
index e0b9012..34dd338 100644
--- a/machines/chungus/configuration.nix
+++ b/machines/chungus/configuration.nix
@@ -71,7 +71,7 @@
   features.boot.tor.enable = true;
 
   telemetry.enable = true;
-  telemetry.opentelemetry.receiver.endpoint = "0.0.0.0:4317";
+  telemetry.apps.opentelemetry.receiver.endpoint = "0.0.0.0:4317";
   networking.firewall.interfaces.wg0.allowedTCPPorts = [ 4317 ];
   networking.firewall.interfaces.wg0.allowedUDPPorts = [ 4317 ];
 
diff --git a/machines/chungus/telemetry/prometheus.nix b/machines/chungus/telemetry/prometheus.nix
index 18cb59d..c4ebb67 100644
--- a/machines/chungus/telemetry/prometheus.nix
+++ b/machines/chungus/telemetry/prometheus.nix
@@ -22,12 +22,8 @@
     };
   };
 
-  services.prometheus = {
-    checkConfig = "syntax-only";
-    enable = true;
-    # keep data for 30 days
-    extraFlags = [ "--storage.tsdb.retention.time=90d" ];
-  };
+  telemetry.apps.prometheus.enable = true;
+  telemetry.apps.prometheus.retentionTime = "90d";
 
   services.grafana.provision.datasources.settings = {
     apiVersion = 1;
diff --git a/machines/orbi/configuration.nix b/machines/orbi/configuration.nix
index 3bb56b6..562f1e4 100644
--- a/machines/orbi/configuration.nix
+++ b/machines/orbi/configuration.nix
@@ -67,8 +67,8 @@
   features.boot.ssh.enable = true;
 
   telemetry.enable = true;
-  telemetry.opentelemetry.receiver.endpoint = "0.0.0.0:4317";
-  telemetry.opentelemetry.exporter.endpoint = "10.100.0.2:4317"; # chnungus
+  telemetry.apps.opentelemetry.receiver.endpoint = "0.0.0.0:4317";
+  telemetry.apps.opentelemetry.exporter.endpoint = "10.100.0.2:4317"; # chnungus
   networking.firewall.interfaces.wg0.allowedTCPPorts = [ 4317 ];
   networking.firewall.interfaces.wg0.allowedUDPPorts = [ 4317 ];
   healthchecks.closed.public.ports.opentelemetry = [ 4317 ];