filter{
ruby { code => 'event.set("patternmatch1", event.get("message").scan(/TEXT.*?(\w[\w,.]*)\r?$/))'
}
# Retrieve the length of the array containing all the matches
ruby { code => 'event.set("number_of_elements", event.get("patternmatch4").length-1)'
}
I would like to use the array length as the index of a ruby array of patterns to choose index pattern that i want. I am looking for element in last index of array
If the field "number_of_elements" is only needed for getting the last element of a field named "patternmatch4", you can just use the [-1] index in Ruby instead.
If you really need the number_of_elements field (which actually contains the total number - 1 to match the index of the last element of the array) , here it is another example that might serve as inspiration to work with your patterns array:
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.