about summary refs log tree commit diff
diff options
context:
space:
mode:
authorzimbatm <zimbatm@zimbatm.com>2024-11-22T18·47+0100
committerJonas Chevalier <zimbatm@zimbatm.com>2024-11-23T09·41+0000
commite58e6f6e16c8ee8c0714aafe75cc66ec59c6088d (patch)
tree3fb9c06dd53afc077dc2b1798c6f2187a36cef1c
parent378a6faec25b1332415c55658e09d23804fff995 (diff)
feat(users/flokli/nixos/nixos-tvix-cache): also collect system metrics r/8956
Use grafana-alloy to collect system metrics.

Change-Id: I592e64ca722701d4f12e69a531a434b54954955a
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12827
Reviewed-by: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
-rw-r--r--users/flokli/nixos/nixos-tvix-cache/monitoring.nix26
1 files changed, 26 insertions, 0 deletions
diff --git a/users/flokli/nixos/nixos-tvix-cache/monitoring.nix b/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
index 32cb7ddc0e11..77bca42d633f 100644
--- a/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
+++ b/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
@@ -34,6 +34,32 @@ in
     };
   };
 
+  services.alloy.enable = true;
+
+  environment.etc."alloy/config.alloy".text = ''
+    prometheus.exporter.unix "main" { }
+
+    prometheus.scrape "main" {
+      targets    = prometheus.exporter.unix.main.targets
+      forward_to = [otelcol.receiver.prometheus.default.receiver]
+    }
+
+    otelcol.receiver.prometheus "default" {
+      output {
+        metrics = [otelcol.exporter.otlp.default.input]
+      }
+    }
+
+    otelcol.exporter.otlp "default" {
+      client {
+        endpoint = "127.0.0.1:4317"
+        tls {
+          insecure = true
+        }
+      }
+    }
+  '';
+
   services.opentelemetry-collector = {
     enable = true;
     settings = {