Hi,
How to write pattern inside multiline codec to append the data till nth occurrence of the string.
Like eg-
File content is this:
public class Constr1 { private int a; public Constr1 () { Constr1 Constr1 Constr1 //super(); a = 1; //super(); } }
regex- (?:.?(Constr1)+){3}.?((Constr1)+)
Result - https://regex101.com/r/nM6qN0/1
Above pattern is working fine in online regular expression but while using in logstash its not working. My config file looks below:
input {
file {
path => "Data.log"
start_position => beginning
sincedb_path=>"/dev/null"
codec => multiline {
pattern =>"(?:.*?(Constr1)+){3}"
negate =>"false"
what =>"previous"
}
}
}
output {
file {
codec => line {
format => "%{[time]} - %{[message]}"
}
path => "/Users/dnataraj1/Desktop/Goreply_preprod_logs/test/reqresp-%{+YYYY-MM-dd}123.log"
}
}
Please help.