about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-11-22T20·27+0200
committerflokli <flokli@flokli.de>2024-11-23T09·44+0000
commitcb85e87376138670e1ef9b2ca8a5746575e7564c (patch)
treed161e3a8ce7082ed864c6b2b78f5801222c930a0
parent09b343864ae7e2b8ffbcf71b086904eac8827007 (diff)
refactor(users/flokli/nixos-tvix-cache): absorb otlpcollector into alloy r/8958
We don't need a separate instance of opentelemetry-collector, alloy can
also do this job for us.

Change-Id: I1b671ba57d70b080f7db112e1afcfe2e0cbdd13e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12829
Reviewed-by: flokli <flokli@flokli.de>
Reviewed-by: Jonas Chevalier <zimbatm@zimbatm.com>
Tested-by: BuildkiteCI
-rw-r--r--users/flokli/nixos/nixos-tvix-cache/monitoring.nix82
1 files changed, 33 insertions, 49 deletions
diff --git a/users/flokli/nixos/nixos-tvix-cache/monitoring.nix b/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
index ee7a61a2f57d..d7c54c6a1434 100644
--- a/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
+++ b/users/flokli/nixos/nixos-tvix-cache/monitoring.nix
@@ -39,71 +39,55 @@ in
   services.alloy.enable = true;
 
   environment.etc."alloy/config.alloy".text = ''
-    prometheus.exporter.unix "main" { }
+    // Accept OTLP. Forward metrics to victoriametrics, and traces to tempo.
+    otelcol.receiver.otlp "main" {
+      grpc {
+        endpoint = "[::1]:4317"
+      }
 
-    prometheus.scrape "main" {
-      targets    = prometheus.exporter.unix.main.targets
-      forward_to = [otelcol.receiver.prometheus.default.receiver]
-    }
+      http {
+        endpoint = "[::1]:4318"
+      }
 
-    otelcol.receiver.prometheus "default" {
       output {
-        metrics = [otelcol.exporter.otlp.default.input]
+        metrics = [otelcol.exporter.otlphttp.victoriametrics.input]
+        traces = [otelcol.exporter.otlp.tempo.input]
       }
     }
 
-    otelcol.exporter.otlp "default" {
+    // We push to Tempo over otlp-grpc.
+    otelcol.exporter.otlp "tempo" {
       client {
-        endpoint = "127.0.0.1:4317"
+        endpoint = "127.0.0.1:4319"
         tls {
           insecure = true
         }
       }
     }
-  '';
 
-  services.opentelemetry-collector = {
-    enable = true;
-    settings = {
-      receivers = {
-        otlp.protocols.grpc.endpoint = "127.0.0.1:4317";
-        otlp.protocols.http.endpoint = "127.0.0.1:4318";
-      };
+    // We push to VictoriaMetrics over otlp-http.
+    otelcol.exporter.otlphttp "victoriametrics" {
+      client {
+        endpoint = "http://localhost:8428/opentelemetry"
+      }
+    }
 
-      processors = {
-        batch = { };
-      };
+    // Run a bundled node-exporter.
+    prometheus.exporter.unix "main" { }
 
-      exporters = {
-        otlp = {
-          endpoint = "127.0.0.1:4319"; # Tempo otlp-grpc
-          tls.insecure = true;
-        };
-        "otlphttp/metrics" = {
-          compression = "gzip";
-          encoding = "proto";
-          endpoint = "http://localhost:8428/opentelemetry";
-          tls.insecure = true;
-
-        };
-      };
+    // Scrape it.
+    prometheus.scrape "main" {
+      targets    = prometheus.exporter.unix.main.targets
+      forward_to = [otelcol.receiver.prometheus.default.receiver]
+    }
 
-      service = {
-        pipelines = {
-          traces = {
-            receivers = [ "otlp" ];
-            processors = [ "batch" ];
-            exporters = [ "otlp" ];
-          };
-          metrics = {
-            receivers = [ "otlp" ];
-            processors = [ "batch" ];
-            exporters = [ "otlphttp/metrics" ];
-          };
-        };
-      };
-    };
-  };
+    // Convert Prometheus metrics to OTLP and export them.
+    otelcol.receiver.prometheus "default" {
+      output {
+        metrics = [otelcol.exporter.otlphttp.victoriametrics.input]
+      }
+    }
+  '';
 
   services.victoriametrics.enable = true;