Hi ,
I was trying to compare two string in logstash ruby filter inside code , it it always showing wrong result . same if I am trying in ruby IDE is working perfectly fine .
I am trying to do something
code => "
event['id']=File.open('D:/json/samplefile2.txt', &:readline)
latestid=File.open('D:/json/samplefile2.txt', &:readline)
previousid=File.open('D:/json/rubycheck.txt', &:readline)
if(latestid.eql?(previousid) )
event['check'] = 'oldid'
else
event['check'] = 'latestid'
end
File.open('D:/json/rubycheck.txt', 'w') {|rubycheck| rubycheck.truncate(0) }
previousIDfile = File.open('D:/json/rubycheck.txt', 'w')
previousIDfile.puts (File.open('D:/json/samplefile2.txt', &:readline))
previousIDfile.close
"
OR
if x==y
event['check'] = 'oldid'
else
event['check'] = 'latestid'
end
It was not working so I thought to do it with logstash so I have changed it
if[oldid] == [newid] #or I tried if[oldid] == "%{newid}"
{
mutate {
add_field => ["status" , "old"]
}
}
else
{
mutate {
add_field => ["status" , "latest"]
}
}
Its not working , any idea why . and how we can resolve it ?