From cb85e87376138670e1ef9b2ca8a5746575e7564c Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Fri, 22 Nov 2024 22:27:37 +0200 Subject: refactor(users/flokli/nixos-tvix-cache): absorb otlpcollector into alloy 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 Reviewed-by: Jonas Chevalier Tested-by: BuildkiteCI --- users/flokli/nixos/nixos-tvix-cache/monitoring.nix | 82 +++++++++------------- 1 file 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; -- cgit 1.4.1