Commit 61542184ef17

Vincent Demeester <vincent@sbr.pm>
2025-12-19 10:24:14
feat(monitoring): enable Docker Prometheus metrics on container hosts
- Monitor container resource usage, health checks, and lifecycle events - Track Docker daemon performance across sakhalin and aomi - Enable infrastructure observability for containerized workloads Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 7a4c1e7
Changed files (3)
systems
systems/aomi/openshift-port-forward.nix
@@ -73,6 +73,9 @@
               # Allow Prometheus node exporter
               tcp dport 9000 accept
 
+              # Allow Docker Prometheus metrics
+              tcp dport 9323 accept
+
               # Allow libvirt
               tcp dport 16509 accept
 
systems/common/services/docker.nix
@@ -10,6 +10,7 @@
         userland-proxy = true;
         experimental = true;
         bip = "172.26.0.1/16";
+        metrics-addr = "0.0.0.0:9323";
         features = {
           buildkit = true;
         };
@@ -28,4 +29,5 @@
   environment.systemPackages = with pkgs; [ docker-buildx ];
   networking.firewall.trustedInterfaces = [ "docker0" ];
   networking.firewall.checkReversePath = false;
+  networking.firewall.allowedTCPPorts = [ 9323 ]; # Docker Prometheus metrics
 }
systems/sakhalin/extra.nix
@@ -65,6 +65,19 @@ let
   exportarrTargets = lib.mapAttrsToList (
     _name: cfg: "rhea.sbr.pm:${toString cfg.port}"
   ) exportarrServices;
+
+  # Docker hosts with metrics enabled
+  dockerMachines = lib.filterAttrs (
+    _name: _machine:
+    builtins.elem _name [
+      "sakhalin"
+      "aomi"
+    ]
+  ) globals.machines;
+  dockerTargets = monitoring.mkPrometheusTargets {
+    machines = dockerMachines;
+    port = 9323;
+  };
 in
 {
 
@@ -259,6 +272,14 @@ in
           metrics_path = "/api/prometheus";
           bearer_token_file = config.age.secrets."homeassistant-prometheus-token".path;
         }
+        {
+          job_name = "docker";
+          static_configs = [
+            {
+              targets = dockerTargets;
+            }
+          ];
+        }
       ];
     };