How can I check if the "tags" array is empty?


#1

Hi All,

How can I check if the "tags" array has any elements? I am adding and removing tags in my pipeline. At the end there are some messages that end up with an empty tags array ("tags" => []). I will like to check if the array is empty, and if it is I will like to remove the tags field. Is this possible?

Thanks!


How to tell if "tags" array is empty in LS 6
How to check, if a hash is empty (no keys)
Never ending story: how to check and remove empty fields, arrays etc
(Magnus B├Ąck) #2
if [tags] == [] {
  mutate {
    remove_field => ["tags"]
  }
}

#3

Awesome! Thanks!


(system) #4