diff --git a/k8s/loki/templates/podlogs.yaml b/k8s/loki/templates/podlogs.yaml index 381e9a8..ac22f57 100644 --- a/k8s/loki/templates/podlogs.yaml +++ b/k8s/loki/templates/podlogs.yaml @@ -46,11 +46,11 @@ spec: - cri: {} - regex: # Capture into a temporary variable 'raw_level' to avoid overwriting existing logic - # Matches: [LEVEL] anywhere in the line, allowing for whitespace - expression: '\[\s*(?PDEBUG|INFO|WARN|ERROR|LOG|TRACE)\s*\]' + # Matches any of the keywords anywhere in the line, potentially surrounded by ANSI codes/junk + expression: '(?PDEBUG|INFO|WARN|ERROR|LOG|TRACE)' - template: source: level - # If raw_level exists (regex matched), map it. Otherwise, default to 'unknown' to verify config application. - template: '{{ "{{" }} if eq .Extraction.raw_level "LOG" {{ "}}" }}info{{ "{{" }} else if eq .Extraction.raw_level "WARN" {{ "}}" }}warn{{ "{{" }} else if eq .Extraction.raw_level "ERROR" {{ "}}" }}error{{ "{{" }} else if eq .Extraction.raw_level "DEBUG" {{ "}}" }}debug{{ "{{" }} else if .Extraction.raw_level {{ "}}" }}{{ "{{" }} .Extraction.raw_level | lower {{ "}}" }}{{ "{{" }} else {{ "}}" }}unknown{{ "{{" }} end {{ "}}" }}' + # Use contains logic to match the extracted level keyword + template: '{{ "{{" }} if contains .Extraction.raw_level "ERROR" {{ "}}" }}error{{ "{{" }} else if contains .Extraction.raw_level "WARN" {{ "}}" }}warn{{ "{{" }} else if contains .Extraction.raw_level "DEBUG" {{ "}}" }}debug{{ "{{" }} else if contains .Extraction.raw_level "TRACE" {{ "}}" }}trace{{ "{{" }} else if .Extraction.raw_level {{ "}}" }}info{{ "{{" }} else {{ "}}" }}unknown{{ "{{" }} end {{ "}}" }}' - labels: level: level