Would like to collect hotelCodes from JSON and create as a list to show in Kibana. Started writing to create array using ruby code in log stash config as below, but its not giving any NEW array as output in kibana, no errors while starting logstash pipeline.
The problem is that [data][OTAHotelAvailRS][errorsOrHotelStaysOrRoomStays] is an array. You'll have to iterate over the items in that array and act on the object with a roomStay key. It's the array the roomStay key points to that you can run collect on.
Have solved this problem. I wanted to add here this ruby code that might be useful for others doing this:
if(!event.get("[data][OTAHotelAvailRS][errorsOrHotelStaysOrRoomStays]").nil?)
# Find roomStay keyed element from OTAHotelAvailRS to make RoomStays Object
event.set("[roomStays]", event.get("[data][OTAHotelAvailRS][errorsOrHotelStaysOrRoomStays]").find { |h| h['roomStay'] })
# Collect all hotelCodes from RoomStays array
if(!event.get("[roomStays][roomStay]").nil?)
event.set("[hotelCodes]", event.get("[roomStays][roomStay]").collect { |h| h['basicPropertyInfo']['hotelCode'] })
end
end
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.