controller: nameOverride: "alloy-node-scrapper" volumes: extra: # requires host journal configuration storage = volatile - name: run-log-journal hostPath: path: /run/log/journal # Log scrapers (e.g., Alloy/Loki) read this ID from the journal metadata and use it to separate log streams per machine. - name: etc-machine-id hostPath: path: /etc/machine-id tolerations: - key: "node-role.kubernetes.io/control-plane" operator: "Exists" effect: "NoSchedule" - key: "infra.limbosolutions.com/dedicated" operator: "Exists" effect: "NoSchedule" alloy: mounts: varlog: true # Mounts /var/log from the host (persistent journal) extra: # requires host journal configuration storage = volatile - name: run-log-journal mountPath: /run/log/journal readOnly: true # required - name: etc-machine-id mountPath: /etc/machine-id readOnly: true # https://grafana.com/docs/alloy/latest/collect/logs-in-kubernetes/ configMap: content: | // ============================================ // LOKI WRITE TARGET // ============================================ loki.write "loki_srv" { endpoint { url = env("LOKI_URL") } } // ============================================ // HOST JOURNALD SOURCE // ============================================ // Read journald logs from the host loki.source.journal "journal" { max_age = "24h" relabel_rules = discovery.relabel.host_journal.rules forward_to = [loki.process.host_journal.receiver] } // ============================================ // HOST JOURNALD RELABELING // ============================================ // Convert journald metadata into Loki labels discovery.relabel "host_journal" { targets = [] // Systemd unit name rule { source_labels = ["__journal__systemd_unit"] target_label = "systemd_unit" } // Transport type (stdout, syslog, kernel, audit, etc.) rule { source_labels = ["__journal__transport"] target_label = "journal_transport" } // Priority (info, warning, error) rule { source_labels = ["__journal_priority_keyword"] target_label = "level" } } // ============================================ // HOST JOURNALD PROCESSING // ============================================ // Add static labels and forward journald logs to Loki loki.process "host_journal" { stage.static_labels { values = { cluster = env("CLUSTER_NAME"), host = env("NODE_NAME"), zone = env("ZONE"), job = "journald", service_name = "journald", } } forward_to = [loki.write.loki_srv.receiver] } extraEnv: - name: NODE_NAME valueFrom: fieldRef: fieldPath: spec.nodeName - name: CLUSTER_NAME value: casa - name: ZONE value: casa-vlan - name: LOKI_URL valueFrom: secretKeyRef: name: alloy-global key: loki_url