# Logstash is it possible to drop only field?

**URL:** https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116
**Category:** Logstash
**Created:** [June 28, 2017, 2:19pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116 "2017-06-28T14:19:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)
#### Post date: [June 28, 2017, 2:19pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116/1 "2017-06-28T14:19:45Z")

</div>

Hi,

My usecase i want to drop a field if it doesnt satisfy the value like

```
if [ServerName] ! "data-0","data-1","data-2" 
  drop ServerName

```

(i.e. I want to drop the ServerName field in an event if it doesn't have either data-0,data-1,data-2 in it.

Note: I dont want to stop the whole event i just want to drop only the ServerName field.

Thanks

---

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [June 28, 2017, 2:29pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116/2 "2017-06-28T14:29:56Z")

</div>

I think mutate should do trick for you [https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-remove\_field](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-remove_field)

---

<div class="post-metadata">

### Author: ![Yaswanth](https://avatars.discourse-cdn.com/v4/letter/y/94ad74/32.png) [@Yaswanth](https://discuss.elastic.co/u/Yaswanth)
#### Post date: [June 28, 2017, 2:33pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116/3 "2017-06-28T14:33:41Z")

</div>

Thanks  
Looking into it but i want to check not equal condition on 3 strings in ServerName field

```
if !("SERVERNAME" in ["esndata-0", "esndata-1", "esndata-2"]) {
    mutate { add_tag => "shouldexist" }
  }
}

```

That is if SERVERNAME doesnt have either of the given strings then it should add a tag.

Is the above syntax is correct?  
Thanks

---

<div class="post-metadata">

### Author: ![ld\_pvl](https://avatars.discourse-cdn.com/v4/letter/l/cdc98d/32.png) [@ld\_pvl](https://discuss.elastic.co/u/ld_pvl)
#### Post date: [June 28, 2017, 2:43pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116/4 "2017-06-28T14:43:07Z")

</div>

Syntax not exactly correct, uncle google is your friend - this should help [https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html#conditionals)

---

<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 26, 2017, 2:43pm UTC](https://discuss.elastic.co/t/logstash-is-it-possible-to-drop-only-field/91116/5 "2017-07-26T14:43:43Z")

</div>

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