# Grafana Alloy: ships the full systemd journal to Loki. # The nixpkgs module reads /etc/alloy/*.alloy and already runs with the # systemd-journal supplementary group. Alloy exposes /metrics + UI on :12345. { config, lib, ... }: let cfg = config.my.profiles.monitoring; in { config = lib.mkIf cfg.enable { services.alloy.enable = true; environment.etc."alloy/config.alloy".text = '' loki.source.journal "journal" { max_age = "24h" forward_to = [loki.write.local.receiver] relabel_rules = loki.relabel.journal.rules labels = { host = "jupiter" } } loki.relabel "journal" { forward_to = [] rule { source_labels = ["__journal__systemd_unit"] target_label = "unit" } rule { source_labels = ["__journal_priority_keyword"] target_label = "priority" } rule { source_labels = ["__journal__transport"] target_label = "transport" } rule { source_labels = ["__journal__boot_id"] target_label = "boot_id" } } loki.write "local" { endpoint { url = "http://127.0.0.1:3100/loki/api/v1/push" } } ''; }; }