If Array element not present

Is there a way to only set a field to an array element when its populated?

     split => { "HOSTALIAS" => ", " }
      add_field => {
                "ci_alias" => "%{[HOSTALIAS][0]}"
                "blueprint-id" => "%{[HOSTALIAS][1]}"
                "instance-id" => "%{[HOSTALIAS][2]}"
	        "vm-location" => "%{[HOSTALIAS][3]}"

This works fine when all elemnts of the array are populated, but in the instance that [3] isnt sent, I get

"vm-location" => "%{[HOSTALIAS][3]}",

Is there a way to check this, without doing a lot of 'if' statements to check?

Not that I can think of.

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