Expecte
Here are some logs:
2023-03-20 13:17:21.625 [INFO] (?P<msg>)
2023-03-20 13:17:21.625 [INFO] {08762e5dd8084e176b6780683d9ae896} (?P<msg>)
2023-03-20 13:17:21.629 [DEBU] {6471af92d9084e178dfedd11c98d743d} (?P<msg>)
I hope to see level=debug
in grafana instead of unknown
What I did
I checked the related issues: Loki does not recognize log level `ERRO` · Issue #7944 · grafana/loki, Promtail: replace stage can`t replace GUID · Issue #8344 · grafana/loki
I try to add a stage , but it didn’t work:
- replace:
expression: "(?P<level>DEBU)"
source: level
replace: "debug"
- replace:
expression: "(?P<level>ERRO)"
source: level
replace: "error"
ENV
promtail
- version: 2.7.3
- OS/Arch: window 10/amd64
loki
- docker image: grafana/loki:2.7.3
- docker version: 23.0.1
- docker OS/Arch: linux/amd64
More info
promtail config.yml
:
scrape_configs:
- job_name: job
static_configs:
- labels:
__path__: /var/log
pipeline_stages:
- multiline:
firstline: '^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}'
max_wait_time: 3s
- regex:
expression: '(?P<time>^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) \[(?P<level>[A-Z]+)\]( {(?P<trace>\w*)}){0,1} (?P<msg>(.|\n)*$)'
- labels:
time:
level:
trace:
- replace:
expression: "(?P<level>DEBU)"
source: level
replace: "debug"
- replace:
expression: "(?P<level>ERRO)"
source: level
replace: "error"
- timestamp:
source: time
format: '2006-01-02 15:04:05.000'
- output:
source: msg
Thanks in advance.