diff --git a/modules/mixins/alloy-forwarder/config.alloy b/modules/mixins/alloy-forwarder/config.alloy index 74c3f85..1101c20 100644 --- a/modules/mixins/alloy-forwarder/config.alloy +++ b/modules/mixins/alloy-forwarder/config.alloy @@ -50,19 +50,12 @@ loki.source.api "receive" { listen_address = "0.0.0.0" listen_port = 3100 } - forward_to = [ - grafana_cloud.stack.receivers.logs, - ] + forward_to = [grafana_cloud.stack.receivers.logs] } loki.source.journal "read" { - forward_to = [ - grafana_cloud.stack.receivers.logs, - ] - relabel_rules = concat( - loki.relabel.journal.rules, - loki.relabel.instance.rules, - ) + forward_to = [grafana_cloud.stack.receivers.logs] + relabel_rules = loki.relabel.omnibus.rules labels = { "job" = "integrations/node_exporter", } diff --git a/modules/mixins/alloy/base.alloy b/modules/mixins/alloy/base.alloy index 6310d60..f4db4fd 100644 --- a/modules/mixins/alloy/base.alloy +++ b/modules/mixins/alloy/base.alloy @@ -3,19 +3,14 @@ local.file "hostname" { filename = "/etc/hostname" } -// Set hostname from /etc -loki.relabel "instance" { +// Loki journal relabeller +loki.relabel "omnibus" { forward_to = [] rule { target_label = "instance" replacement = local.file.hostname.content } -} - -// Loki journal relabeller -loki.relabel "journal" { - forward_to = [] rule { source_labels = ["__journal__systemd_unit"] diff --git a/modules/mixins/alloy/config.alloy b/modules/mixins/alloy/config.alloy index 554b4a6..3f341ff 100644 --- a/modules/mixins/alloy/config.alloy +++ b/modules/mixins/alloy/config.alloy @@ -32,30 +32,30 @@ loki.relabel "journal" { forward_to = [] rule { - source_labels = ["__journal__systemd_unit"] - target_label = "unit" + target_label = "instance" + replacement = local.file.hostname.content } rule { - source_labels = ["__journal_container_name"] - target_label = "container_name" + source_labels = ["__journal__systemd_unit"] + target_label = "unit" } rule { - source_labels = ["__journal_image_name"] - target_label = "container_image" + source_labels = ["__journal__boot_id"] + target_label = "boot_id" } rule { - source_labels = ["__journal_container_id"] - target_label = "container_id" + source_labels = ["__journal__transport"] + target_label = "transport" } } // Fetch journal entries loki.source.journal "journal" { forward_to = [otelcol.receiver.loki.default.receiver] - relabel_rules = loki.relabel.journal.rules + relabel_rules = loki.relabel.omnibus.rules labels = {component = "loki.source.journal"} } diff --git a/modules/mixins/ecs-agent/config.alloy b/modules/mixins/ecs-agent/config.alloy index ede3c60..70bc7f1 100644 --- a/modules/mixins/ecs-agent/config.alloy +++ b/modules/mixins/ecs-agent/config.alloy @@ -1,8 +1,5 @@ prometheus.scrape "ecs_agent" { - targets = [ - {"__address__" = "127.0.0.1:51680", instance = env("HOSTNAME")}, - ] - + targets = [{"__address__" = "127.0.0.1:51680"}] forward_to = [prometheus.relabel.instance.receiver] scrape_interval = "30s" }