// Ansible managed — generated from alloy.config.alloy.j2 // Grafana Alloy log shipping agent — {{ inventory_hostname }} // ─── System logs ───────────────────────────────────────────────────────────── {% if ansible_facts['os_family'] == 'Debian' %} loki.source.journal "system" { forward_to = [loki.write.default.receiver] labels = {"host" = "{{ inventory_hostname }}"} relabel_rules = loki.relabel.journal.rules } loki.relabel "journal" { forward_to = [] rule { source_labels = ["__journal__systemd_unit"] target_label = "unit" } rule { source_labels = ["__journal_priority_keyword"] target_label = "level" } } {% elif ansible_facts['os_family'] == 'Alpine' %} local.file_match "system" { path_targets = [ {"__path__" = "/var/log/messages", "job" = "messages", "host" = "{{ inventory_hostname }}"}, ] } {% elif ansible_facts['os_family'] == 'FreeBSD' %} local.file_match "system" { path_targets = [ {"__path__" = "/var/log/messages", "job" = "syslog", "host" = "{{ inventory_hostname }}"}, {"__path__" = "/var/log/auth.log", "job" = "auth", "host" = "{{ inventory_hostname }}"}, ] } {% endif %} {% if ansible_facts['os_family'] != 'Debian' %} loki.source.file "system" { targets = local.file_match.system.targets forward_to = [loki.write.default.receiver] } {% endif %} {% if inventory_hostname == 'london-b' %} // ─── london-b app logs ──────────────────────────────────────────────────────── local.file_match "apps" { path_targets = [ {"__path__" = "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/*.log", "job" = "plex", "host" = "london-b"}, {"__path__" = "/var/log/jellyfin/*.log", "job" = "jellyfin", "host" = "london-b"}, ] } loki.source.file "apps" { targets = local.file_match.apps.targets forward_to = [loki.write.default.receiver] } {% endif %} // ─── Loki output ────────────────────────────────────────────────────────────── loki.write "default" { endpoint { url = "{{ alloy_loki_url }}" } }