# How to tell if "tags" array is empty in LS 6

**URL:** <https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357>\
**Category:** Logstash\
**Created:** [February 25, 2018, 3:05am UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357 "2018-02-25T03:05:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nick-george](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick-george/32/23318_2.png) [@nick-george](https://discuss.elastic.co/u/nick-george)\
**Post date:** [February 25, 2018, 3:05am UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/1 "2018-02-25T03:05:24Z")

</div>

Hi,

The code here ([How can I check if the "tags" array is empty?](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856)) used to work for checking if tags was empty or not.

```
if [tags] == [] {
  mutate {
    remove_field => ["tags"]
  }
}

```

Unfortunately, it no longer seems to work because I get the following error:

````
main, :exception=>"Java::JavaLang::IllegalArgumentException", :message=>"Failed to parse right-hand side of conditional [str]pipeline:1723:6:```\n[tags] == []\n```

````

If I remove the conditional, the error no longer occurs.

Is there a new LS6 compatible way to check if tags is empty?

Many thanks,  
Nick

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [February 25, 2018, 9:11am UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/2 "2018-02-25T09:11:33Z")

</div>

Have you tried `if not [tags]`?

---

<div class="post-metadata">

**Author:** ![nick-george](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nick-george/32/23318_2.png) [@nick-george](https://discuss.elastic.co/u/nick-george)\
**Post date:** [February 26, 2018, 2:16am UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/3 "2018-02-26T02:16:42Z")

</div>

Thanks Magnus,

Is that test looking to see if the tags field exists, rather than if it's empty? I put that code in specifically to remove the tags field if it contains no elements. In my configuration pipeline, it's possible that I've added values to [tags] and then removed them again by the end of processing.

I guess it's no biggy if tags in hanging around with nothing in it, but it would be nice if the configuration language supported this feature (again).

Cheers,  
Nick

---

<div class="post-metadata">

**Author:** ![siddharthgoel88](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/siddharthgoel88/32/10616_2.png) [@siddharthgoel88](https://discuss.elastic.co/u/siddharthgoel88)\
**Post date:** [March 21, 2018, 6:28am UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/4 "2018-03-21T06:28:14Z")

</div>

Hey Magnus. Does this check for empty tags field? We only want to remove tags field if it is empty. Thanks.

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [March 21, 2018, 8:11pm UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/5 "2018-03-21T20:11:33Z")

</div>

> Does this check for empty tags field?

I believe so, yes.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 18, 2018, 8:11pm UTC](https://discuss.elastic.co/t/how-to-tell-if-tags-array-is-empty-in-ls-6/121357/6 "2018-04-18T20:11:58Z")

</div>

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