Hi Community,
We have a use case to filter a specific log from all log messages which like which looks like this “Critical Message – [Service:ServiceName, Title:Service Started, ErrorCode:CH0000, Severity:INFO, Date:2024-07-19-12-36+0000] Service Version Service Instance restarted” and transform it to json to extact values of key like “Service”,“Title” etc.
i am trying to solve using loki.process, but no luck as of now.
loki.process “alert_logs” {
forward_to = null
stage.pack {
labels = [“filename”,“hostname”,“type”]
}
stage.json {
expressions = {logline = “_entry”}
}
stage.json {
source = "logline"
expressions = {message = ""}
}
stage.labels {
values = { "message" = "" }
}
stage.match{
selector = "{message=\"Critical Message --\"}"
action = "keep"
drop_counter_reason = "non-alert log"
stage.output {
source = "message"
}
}
stage.regex {
expression = `Critical Message -- \[Service:ServiceName, Title:(?P<title>.*), ErrorCode:(?P<errorCode>.*), Severity:(?P<severity>.*), Date:(?P<datetime>.*?)\] (?P<msg>.*)`
}
}
Also is there any way to debug loki.process stages?