Unfotunately, this block does not work (I keep getting errors), this is "expanded" code
filter {
ruby {
code => '
lines = event.get("message").lines(chomp: true)
begin_time = ""
end_time = ""
lines.each { |x|
if x =~ /Begin time:)/
begin_time = x
elsif x =~ /(End time)/
end_time = x
...
In the same file (log) I have begin and end time timestamps, and also couple of other variables.. and all of them works ok if they are on the same line, but cannot succeed to map value from next row, like in example.
[2021-09-17T14:34:16,392][ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of #, => at line 118, column 8 (byte 4435) after filter {\n\truby {\n..
I managed to do something and grok is now working, but since my file has multiple lines after "begin time", it saves under "begin time" field all the rest of the document, how can I make him to store only that one (next) line where the date is?
Thank you, now it looks like:
"begin_time" : """
Sat Jun 26 16:56:16 AEST 2021
rm: cannot remove '/scrXXXX/003': No such file or directory
IDS=4947802324992
ENV=BATCH
LD_LIBRARY_PATH=/apps/ncl/6.6.2/l
...
I'm using chomp true because I'm extracting 30 more fields which are in the same line ( field: value, eg.). Ony begin_time and end_time has value in new line.
I added new message variable and tried out this match, and the result is:
"start_time" : """
Starting time:
Sat Jun 26 16:56:16 AEST 2021
"""
Looks like it should be event.set("begin_time", mdata[1])
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.