I have a ruby filter that puts all mac addresses (access points and stations macs) in a log to mac_addresses field and this works fine.
I also have another grok filter which puts only station mac addresses to station_mac field.
I'm trying to remove station_mac address from mac_addresses array if it has more than one address and then save result in different field.
The code below should be working but it doesn't remove station_mac from array so in result I get new field ap_macs with the same value as in mac_addresses.
ruby {
code => "
if event.get('mac_addresses').length > 1
event.set('ap_macs', event.get('mac_addresses').delete_if { |a| a == event.get('station_mac')})
end"
}
I was thinking of creating a new field [ap_macs] but if it's possible to modify [mac_addresses] then it could be even better. Unfortunatelly I'm not able to get it working either way.
Your ruby code seems OK. There must be something else in the logic of the pipeline ... station_mac not set when the ruby filter executes, ruby filter in a conditional, or something else.
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.