Logstash 处理文件中的多行记录

Logstash Processing Multi Line records from file

我的日志样本是这样的:

2017-01-03 03:38:18 +0000 field1: 123 field2: 321
field3: 1133 field4: 0901
2017-01-03 03:38:19 +0000 field1: 523 field2: 521
field3: 533 field4: 509

我对此很陌生。我应该如何编写正则表达式?

对于文件{}输入,您应该使用multiline codec(而不是多行{}过滤器),例如:

input {
  file {
    path => "..."
    codec => multiline {
      negate => "true"
      pattern => "^%{YEAR}"
      what => "previous"
    }
  }
}

你会读作,"if the line doesn't start with a year, keep it with the previous line"。