From bec3125184dc204f5585a311d335b8076b48442f Mon Sep 17 00:00:00 2001 From: Arne Teuke Date: Tue, 11 Mar 2025 14:09:35 +0100 Subject: [PATCH] revert hostname label --- templates/config.alloy.erb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/templates/config.alloy.erb b/templates/config.alloy.erb index 9132dab..6637418 100644 --- a/templates/config.alloy.erb +++ b/templates/config.alloy.erb @@ -31,6 +31,12 @@ loki.process "parse_hostname" { } } } + // Fallback: Set hostname explicitly if not parsed + stage.static_labels { + values = { + hostname_fallback = system.hostname, // e.g., fm002 + } + } } // Refine labels @@ -50,11 +56,11 @@ loki.relabel "add_labels" { source_labels = ["hostname"] target_label = "hostname" } - //rule { - // source_labels = ["hostname_fallback"] - // target_label = "hostname" - // action = "replace" - // replacement = "${__label:hostname_fallback}" // Only if hostname is unset + rule { + source_labels = ["hostname_fallback"] + target_label = "hostname" + action = "replace" + replacement = "${__label:hostname_fallback}" // Only if hostname is unset } }