HaWell
February 22, 2023, 12:17pm
1
promtail config pipeline_stages.match.stages.timestamp.format
How to format such time [2023-02-22 10:08:21601]
This is my config, but it’s invalid. It doesn’t replace time.
stages:
- regex:
expression: ‘^[(?P\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3})]\s*(?P\w+)\s*[(?P<thread_name>.?)]\s (?P<class_name>.?)\s (?P<method_name>.?)\s [(?P<thread_id>.?)]\s [(?P<trace_id>.?)]\s –\s*(?P.*)$’
- multiline:
firstline: ‘^[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}]’
max_wait_time: 3s
- labels:
level:
thread_name:
class_name:
method_name:
thread_id:
trace_id:
- timestamp:
format: “yyyy-MM-dd HH:mm:ss,SSS”
source: timestamp
Try to match the entire timestamp with regex, then format it with timestamp
. Notice when you specify timestamp you give it a source timestamp
, but it is nowhere to be found in your regex. So I’d try this:
-regex
expression: '^[(?P<reg_timestamp>.*)]\s*(?P\w+)\s*[(?P<thread_name>.?)]\s(?P<class_name>.?)\s(?P<method_name>.?)\s[(?P<thread_id>.?)]\s[(?P<trace_id>.?)]\s–\s*(?P.*)$''
...
- timestamp:
format: "2006-01-02 15:04:05,000"
source: reg_timestamp
1 Like
HaWell
February 23, 2023, 5:15am
3
This answer is very good. Thank you very much
1 Like
system
Closed
February 23, 2024, 5:15am
4
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.