Hello, I am trying to extract the http methods and status code as log lables from my docker container logs.
The log lines are already in lofmt format, log example as ggiven below.
ts=2025-07-17 16:52:27,743 level=INFO line=97 msg=“172.19.0.7 - - [17/Jul/2025 16:52:27] “GET /plants/2 HTTP/1.1” 200 -”
When I use logfmt filter on log query in grafana explorer it identify “msg” as lable and only provide value as 172.19.0.7 - - [17/Jul/2025 16:52:27] .
I tried using regex expression and logfmt but that didn’t work.
Below is my loki.process config
loki.process “getting_started” {
stage.decolorize {}
// stage.logfmt {
// mapping = { “msg” = “” }
//}
stage.json{
expressions = { msg = “” }
}
stage.regex {
expression = “^(?P\S+) (?P\S+) (?P\S+) \[(?P[^\]]+)\] \"(?P\S+) (?P[^ ]+) (?P[^"]+)\" (?P\d{3}) (?P\S+)$”
source = “msg”
}
stage.static_labels {
values = {
env = “Development”,
}
}
forward_to = [loki.write.getting_started.receiver]
}