fix(alloy): fix log level parser

- remove parser for JSON and logfmt, and add regex expression to extract the level of log
This commit is contained in:
2026-04-13 10:42:10 +09:00
parent da016343c0
commit 7debdfcb93

View File

@@ -203,17 +203,11 @@ loki.relabel "caddy_relabel" {
loki.process "journal_parser" {
forward_to = [loki.write.loki.receiver]
// Severity parsing
// If content of log includes "level" information, change the level
stage.json {
expressions = {
"content_level" = "level",
}
}
stage.logfmt {
mapping = {
"content_level" = "level",
}
stage.regex {
// Regex to extract the log level from the content.
expression = "(?i)(?:level[\"\\s:=]+|\\[|\\s|^)(?P<content_level>info|warn|warning|error|debug|fatal|critical|trace)(?:[\"\\]\\s]|$)"
}
stage.labels {
values = {
"level" = "content_level",