Logstash Multiline filter

2019-07-16 05:14发布

问题:

We have some files that are written out to our web servers whenever we have php errors. Each error has it's own file, but there are always multiple lines in each file. The files always start with the text "Excepton:". Is there a way to easily just say, "take the whole file as a log event?" See example below:

Exception: ABC_Exception_Domain -- Message: There is no valid performance dimension for the given nodeRootId.
Error Date and Time:
    Date: September 25, 2014
    Time: 10:38:15
    Timestamp: 1411659495
    PersonId: 3947680
    ProcessId: 18055
    Memory Usage: 18194784
    Machine Id:...

and here is my configuration file that I am using to test output:

input {
  file {
    type => "stack_trace"
    path => [ "/root/20[1-9][0-9]*" ]
    start_position => "beginning"
  }
}
filter {
  multiline {
    type => "stack_trace"
    pattern => "^Exception.*$"
    negate => true
    what => "previous"
  }
}
output {
   stdout {
      codec => rubydebug
   }
}

I have also tried this to use the last line as the log delimiter:

input {
  file {
    type => "stack_trace"
    path => [ "/root/20[1-9][0-9]*" ]
    start_position => "beginning"
  }
}
filter {
  multiline {
    type => "stack_trace"
    pattern => "^#[0-9]{1,3} \{main\}.*$"
    negate => true
    what => "previous"
  }
}
output {
   stdout {
      codec => rubydebug
   }
}

The only way I ever get any results is if I update the files manually and add another Exception or main line.

Thanks in advance for any help, and let me know if I can provide anymore information. Thanks,

Chris.