小编kmk*_*amy的帖子

Fluentd 日志源格式 RegEX

我有这种格式的日志:

2015-02-25 18:33:06,975 INFO c.a.p.c.b.s.Monitor akka://application/user/daemons/monitor : 91 active threads, 4175691776 bytes used
Run Code Online (Sandbox Code Playgroud)

我想到了这个正则表达式:

(?<time>[^ ]* [^ ]*) (?<method>[^ ]*) (?<path>[^ ]*) (?<message>[^ ].*$)
Run Code Online (Sandbox Code Playgroud)

当我在Fluentular 中测试时 (我将使用它作为 fluentd 日志输入的格式)我得到以下字段:

time  =>    2015/02/25 18:33:06 +0000
method  =>    INFO
PATH    =>  <empty>
message => c.a.p.c.b.s.Monitor akka://application/user/daemons/monitor : 91 active threads, 4175691776 bytes used
Run Code Online (Sandbox Code Playgroud)

我无法打破消息字符串。我希望匹配的组是:

time  =>    2015/02/25 18:33:06 +0000
method  =>    INFO
PATH  =>    c.a.p.c.b.s.Monitor
message =>    akka://application/user/daemons/monitor : 91 active threads, 4175691776 bytes used
Run Code Online (Sandbox Code Playgroud)

什么是合适的正则表达式

regex fluentd

5
推荐指数
1
解决办法
4340
查看次数

标签 统计

fluentd ×1

regex ×1