Hello Friends!
I have a db field, where the comma seperated ids are stored. I have setup an array of ID => VALUE.
Example:
In DB field cityids , it contains value "2,3,4,5"
Array has
[1=>"Chicago", 2=>"London",3=>"Delhi",4=>"LA",5=>"Moscow",6=>"Singaport"]
Now, I need to store "London,Delhi,LA,Moscow" in the elastic index using Logstash filter.
Can someone please advise how to achieve this.
I am a PHP person, just have started with Logstash. But, I believe for this I need to use ruby filter, for which I have written the code as below.
filter {
ruby{
code =>"
strPA = event.get('paids')
strPAIds = strPA.split(",")
H = Hash["1" => "Practice Area 1",
"2" => "Practice Area 2",
"3" => "Practice Area 3",
"4" => "Practice Area 4"]
finalpa = ""
strPAIds.each do |strPAIds|
#puts abc
#puts H.fetch(abc)
finalpa = finalpa + H.fetch(strPAIds) + ", "
end
finalpa = finalpa.chomp(" ")
finalpa = finalpa.chomp(",")
event.set('practice_areas',finalpa)
"
}
}
Thank you in advance !
Varshesh