I used this recently at a customer, and it might help point you in the right direction...
# Convert the dates to a proper timestamp.
date {
match => [ "BEGIN", "dd/MM/YYYY HH:mm:ss.SSSSSS" ]
timezone => "UTC"
target => "BEGIN"
}
date {
match => [ "LAST", "dd/MM/YYYY HH:mm:ss.SSSSSS" ]
timezone => "UTC"
target => "LAST"
}
# If the dates parsed properly calculate the runtime in seconds (precision is ms).
if "_dateparsefailure" not in [tags] {
ruby {
code => "
event.set('[RUNTIME_SEC]', (event.get('[LAST]').to_f - event.get('[BEGIN]').to_f).round(3));
"
}
}
That would match if dateLog were something like "Feb 16 14:30:09 2018", but you said it is formatted as "Fri Feb 16 14:30:09 CET 2018". So you need to modify the pattern to include items to match the "Fri" and "CET". The pattern has to match every part of the date string.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.