Loop over array in output


#1

Hello currently I have code that works, but could be improved if I would be able to iterate.
Now I say if the 3rd element of the array exists, output the 3rd element (into a file).
See code below:

output {
  if [value][3] {
    file {
      path => "\\host123\input\file.txt"		
      codec => line { format => "name: '%{name[3]}' value: '%{value[3]}'" }
    } 
  if [value][2] {
    file {
      path => "\\host123\input\file.txt"		
      codec => line { format => "name: '%{name[2]}' value: '%{value[2]}'" }
    } 
  if [value][1] {
    file {
      path => "\\host123\input\file.txt"		
      codec => line { format => "name: '%{name[1]}' value: '%{value[1]}'" }
    } 
  if [value][0] {
    file {
      path => "\\host123\input\file.txt"		
      codec => line { format => "name: '%{name[0]}' value: '%{value[0]}'" }
    } 
}

#2

I found a solution, for my case.
I need to export the data to a other program, but this can handle arrays. So I split it up in there.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.