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

**URL:** https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856
**Category:** Logstash
**Created:** [August 21, 2015, 7:31pm UTC](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856 "2015-08-21T19:31:26Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![spynxo](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@spynxo](https://discuss.elastic.co/u/spynxo)
#### Post date: [August 21, 2015, 7:31pm UTC](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856/1 "2015-08-21T19:31:26Z")

</div>

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!

---

<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: [August 21, 2015, 7:58pm UTC](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856/2 "2015-08-21T19:58:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![spynxo](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@spynxo](https://discuss.elastic.co/u/spynxo)
#### Post date: [August 21, 2015, 8:09pm UTC](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856/3 "2015-08-21T20:09:39Z")

</div>

Awesome! Thanks!

---

<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: [July 6, 2017, 5:31am UTC](https://discuss.elastic.co/t/how-can-i-check-if-the-tags-array-is-empty/27856/4 "2017-07-06T05:31:16Z")

</div>


