# How I can delete element from array?

**URL:** <https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868>\
**Category:** Logstash\
**Created:** [October 30, 2019, 1:28pm UTC](https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868 "2019-10-30T13:28:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gleb](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@gleb](https://discuss.elastic.co/u/gleb)\
**Post date:** [October 30, 2019, 1:28pm UTC](https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868/1 "2019-10-30T13:28:14Z")

</div>

Hello!

I receive messages like this: "app\_risk = 0 app\_risk =2" or "app\_risk = 0"  
After kv filter, I have field "app\_risk": ["0", "2"] or ["0"].  
How I can delete the first element of array - "0", if app\_risk[1] exist ?  
I try to do in filter  
if [app\_risk [1]] == "1"{ mutate {remove\_field =\> ["app\_risk[0]"] }  
but it is not work, because I receive an error with logstash configuration, as I understand I cant use [app\_risk[1]], only [app\_risk].  
How I can do it on Logstash filter?

Thank you for help, good day!!

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [October 30, 2019, 2:40pm UTC](https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868/2 "2019-10-30T14:40:02Z")

</div>

> [@gleb](#):
>
> if [app\_risk [1]] == "1"{ mutate {remove\_field =\> ["app\_risk[0]"] }

That should be

```
if [app_risk][1] { mutate { remove_field => "[app_risk][0]" } }

```

Note that it will still be an array with a single member.

---

<div class="post-metadata">

**Author:** ![gleb](https://avatars.discourse-cdn.com/v4/letter/g/f4b2a3/32.png) [@gleb](https://discuss.elastic.co/u/gleb)\
**Post date:** [October 30, 2019, 3:04pm UTC](https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868/3 "2019-10-30T15:04:47Z")

</div>

Thank you a lot, it is help me!

---

<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:** [November 27, 2019, 3:04pm UTC](https://discuss.elastic.co/t/how-i-can-delete-element-from-array/205868/4 "2019-11-27T15:04:49Z")

</div>

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