From c11896c50c04a993349d53811ed98c9eca43fa99 Mon Sep 17 00:00:00 2001 From: Christine Elisabeth Koppel Date: Sat, 14 Feb 2026 17:19:21 +0100 Subject: [PATCH] Properly convert document as per https://github.com/grafana/alloy/blob/bbe11b0f6a3bd3391108b2d27122c654c535dd8d/docs/sources/set-up/migrate/from-promtail.md --- .../modules/system/gramethus.nix | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/nix-system-configs/modules/system/gramethus.nix b/nix-system-configs/modules/system/gramethus.nix index 105fcf7..a6924fd 100644 --- a/nix-system-configs/modules/system/gramethus.nix +++ b/nix-system-configs/modules/system/gramethus.nix @@ -175,38 +175,33 @@ in { enable = true; }; + # See: https://github.com/grafana/alloy/blob/bbe11b0f6a3bd3391108b2d27122c654c535dd8d/docs/sources/set-up/migrate/from-promtail.md environment.etc."alloy/config.alloy" = { text = '' - loki.relabel "journal" { - rule { - source_labels = ["__journal__systemd_unit"] - target_label = "unit" - } - } + discovery.relabel "journal" { + targets = [] - loki.write "local" { - endpoint { - url = "http://127.0.0.1:3100/loki/api/v1/push" - } - external_labels = {} + rule { + source_labels = ["__journal__systemd_unit"] + target_label = "unit" + } } loki.source.journal "journal" { - max_age = "12h0m0s" + max_age = "12h0m0s" + relabel_rules = discovery.relabel.journal.rules + forward_to = [loki.write.default.receiver] + labels = { + host = "chrysalis", + job = "systemd-journal", + } + } - forward_to = [loki.write.local.receiver] - - labels = { - job = "systemd-journal" - host = "chrysalis" - } - - relabel_rules = loki.relabel.journal.rules - - legacy_position { - file = "/var/lib/grafana-agent/positions.yaml" - name = "journal" - } + loki.write "default" { + endpoint { + url = "http://127.0.0.1:3100/loki/api/v1/push" + } + external_labels = {} } ''; group = "root";