# Add field depending of the dstip

**URL:** <https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568>\
**Category:** Logstash\
**Created:** [November 5, 2019, 9:28am UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568 "2019-11-05T09:28:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![donetz](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@donetz](https://discuss.elastic.co/u/donetz)\
**Post date:** [November 5, 2019, 9:28am UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568/1 "2019-11-05T09:28:53Z")

</div>

Hi community!

I'm using logstash to process some data and I'm in trouble!! This is my situation:

- I'm reading alerts witg Filebeat from a file that has been written by a SIEM.
- I'm receiving these alerts with logstash and I want to check if "dstip" is a concrete one, and then add a field if matched.

Logstash conf:  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/3/73e3277c32eabdc4662feb6ffdf40994cab34e8b.png)

Thanks in advance!!

---

<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:** [November 5, 2019, 3:50pm UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568/2 "2019-11-05T15:50:13Z")

</div>

You are trying to add a field, but you have configured a remove\_field option. Plus, that takes an array, not a hash, so it ends up as a no-op.

---

<div class="post-metadata">

**Author:** ![donetz](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@donetz](https://discuss.elastic.co/u/donetz)\
**Post date:** [November 6, 2019, 9:20am UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568/3 "2019-11-06T09:20:05Z")

</div>

What do you mean when you say that it takes an array?  
I don´t know how add fields to the alert when the dtsip IP is a specific one.  
This is the message I'm receiving.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9bdf138757124bbb133ef639d49ad396aa0c23f3.png)

---

<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:** [November 6, 2019, 2:42pm UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568/4 "2019-11-06T14:42:20Z")

</div>

> [@donetz](#):
>
> What do you mean when you say that it takes an array?

remove\_field needs a list of fields to remove. It does not matter what the values of the fields are, so all it needs is an array of field names.

add\_field needs a list of fields to add and the values that should be added. So it expects a hash.

---

<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:** [December 4, 2019, 2:42pm UTC](https://discuss.elastic.co/t/add-field-depending-of-the-dstip/206568/5 "2019-12-04T14:42:23Z")

</div>

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