Fluentd 日志源格式 RegEX
Fluentd log source format 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
我想到了这个正则表达式:
(?<time>[^ ]* [^ ]*) (?<method>[^ ]*) (?<path>[^ ]*) (?<message>[^ ].*$)
当我在 Fluentular 测试时
(我将使用它作为流利日志输入的格式)我明白了
字段:
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
我无法破解消息字符串。我希望匹配组是:
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
什么是正确的正则表达式
问题是您输入的字符串中 INFO
和 c.a.p.c.b.s.Monitor
之间有两个空格。添加 +
以允许在该位置有一个或多个空格,您将得到:
(?<time>[^ ]* [^ ]*) (?<method>[^ ]*) +(?<path>[^ ]*) (?<message>[^ ].*$)
您可能想也可能不想将它们添加到其余组件中,例如:
(?<time>[^ ]* [^ ]*) +(?<method>[^ ]*) +(?<path>[^ ]*) +(?<message>[^ ].*$)
我有这种格式的日志:
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
我想到了这个正则表达式:
(?<time>[^ ]* [^ ]*) (?<method>[^ ]*) (?<path>[^ ]*) (?<message>[^ ].*$)
当我在 Fluentular 测试时 (我将使用它作为流利日志输入的格式)我明白了 字段:
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
我无法破解消息字符串。我希望匹配组是:
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
什么是正确的正则表达式
问题是您输入的字符串中 INFO
和 c.a.p.c.b.s.Monitor
之间有两个空格。添加 +
以允许在该位置有一个或多个空格,您将得到:
(?<time>[^ ]* [^ ]*) (?<method>[^ ]*) +(?<path>[^ ]*) (?<message>[^ ].*$)
您可能想也可能不想将它们添加到其余组件中,例如:
(?<time>[^ ]* [^ ]*) +(?<method>[^ ]*) +(?<path>[^ ]*) +(?<message>[^ ].*$)