From 7880483b518f0c15aaab518607a8187d9b1be041 Mon Sep 17 00:00:00 2001 From: atlas Date: Wed, 19 Aug 2026 15:31:15 +0200 Subject: [PATCH] swarm-otel: stamp the swarm on every hive's pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mara on the tracking issue: "we need the swarm label for upstream otel at least (the out of swarm one)." Stamped in the per-hive `resource` processor rather than on a separate upstream-only pipeline, which would double the pipeline count to withhold one constant label from the local store. It is redundant there — one metrics store per swarm, so every series in it already belongs to this swarm — but a constant label multiplies no series, and it means what leaves and what stays have the same shape. Upstream is where it stops being redundant: that is the one hop where several swarms can land in one store, and samples that cannot name their swarm collide there exactly as hives collided here before per-hive receivers existed. `unknown` when unnamed rather than an absent label, copying the agent path so a query never has to handle both "the label is missing" and "the label says unknown". --- nix/host-modules/swarm-otel.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/nix/host-modules/swarm-otel.nix b/nix/host-modules/swarm-otel.nix index 525bac27..8f23d3ca 100644 --- a/nix/host-modules/swarm-otel.nix +++ b/nix/host-modules/swarm-otel.nix @@ -70,6 +70,12 @@ let }; caBundle = caTrust.bundlePathFor cfg.machine; + # `unknown` rather than omitting the label, copying `agent-modules/otel.nix` + # deliberately: a producer that cannot name its swarm should say so in the + # same vocabulary as every other producer, so a query never has to handle + # both "the label is absent" and "the label says unknown". + swarmDisplayName = if hyperhiveCfg.swarm.name == null then "unknown" else hyperhiveCfg.swarm.name; + # One list, read by every pipeline: the per-hive pipelines fan out to # exactly the same destinations as the single pipeline they replace. # Written once because "which exporters" is a property of this tier, not @@ -489,6 +495,24 @@ in value = h; action = "upsert"; } + # Stamped here rather than on a separate upstream-only + # pipeline, which would double the pipeline count to + # withhold one constant label from the local store. It + # is redundant there — one VictoriaMetrics per swarm, so + # every series in it already belongs to this swarm — but + # a constant label multiplies no series, and it means + # what LEAVES and what STAYS have the same shape. + # + # Upstream is where it stops being redundant: that is the + # one hop where several swarms can land in one store, and + # samples that cannot name their swarm collide there + # exactly as hives collided here before per-hive + # receivers existed. + { + key = "swarm"; + value = swarmDisplayName; + action = "upsert"; + } ]; } ) hivePorts;