流畅的正则表达式,带有时间戳和消息的字符串

问题描述 投票:-2回答:1

这个字符串有什么好的<source>格式正则表达式?

05.02.2018 15:24:21.999|type|Element1|Element2|message
<source>
  format RegEX?
  path /home/filepath/*.log
  pos_file /var/cache/fluentd/file.pos
  tag mytag
  @type tail
</source>
regex timestamp fluentd
1个回答
0
投票

这是流利的解决方案

format /^(?<time>[^ ]* [^ ]*)\|(?<type>.*)\|(?<Component1>.*)\|(?<SubComponent2>.*)\|(?<message>.*)/ 
time_format %d.%m.%Y %H:%M:%S 
© www.soinside.com 2019 - 2024. All rights reserved.