From 752ac44a52cde5d89a622eb63d2eb5eec7a39e0b Mon Sep 17 00:00:00 2001
From: c6ristian <c6ristian@christian.moe>
Date: Sat, 15 Mar 2025 01:38:57 +0100
Subject: [PATCH] better logging

---
 modules/alloy.nix                             | 7 ++++++-
 systems/monitoring.noc.eh22.intern/system.nix | 3 +++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/alloy.nix b/modules/alloy.nix
index 19d2c52..e601180 100644
--- a/modules/alloy.nix
+++ b/modules/alloy.nix
@@ -58,7 +58,7 @@
         }
         rule {
           source_labels = ["__journal__hostname"]
-          target_label = "systemd_hostname"
+          target_label = "instance"
         }
         rule {
           source_labels = ["__journal__transport"]
@@ -68,11 +68,16 @@
           source_labels = ["__journal_syslog_identifier"]
           target_label = "syslog_identifier"
         }
+        rule {
+          source_labels = ["__journal_priority_keyword"]
+          target_label  = "level"
+        }
       }
 
       loki.source.journal "read_journal"  {
         forward_to    = [loki.write.default.receiver]
         relabel_rules = loki.relabel.journal.rules
+        format_as_json = true
         labels        = {component = "loki.source.journal", host = "${config.networking.hostName}"}
       }
 
diff --git a/systems/monitoring.noc.eh22.intern/system.nix b/systems/monitoring.noc.eh22.intern/system.nix
index 7c1c8ae..cb182a6 100644
--- a/systems/monitoring.noc.eh22.intern/system.nix
+++ b/systems/monitoring.noc.eh22.intern/system.nix
@@ -11,18 +11,21 @@
       owner = "grafana";
       group = "grafana";
       restartUnits = [ "grafana.service" ];
+      sopsFile = ../../secrets/passwords.yaml;
     };
     secrets."services/loki/nginx" = {
       mode = "0440";
       owner = "nginx";
       group = "nginx";
       restartUnits = [ "nginx.service" ];
+      sopsFile = ../../secrets/passwords.yaml;
     };
     secrets."services/mimir/nginx" = {
       mode = "0440";
       owner = "nginx";
       group = "nginx";
       restartUnits = [ "nginx.service" ];
+      sopsFile = ../../secrets/passwords.yaml;
     };
   };