# Remove whole documents with certain value in field

**URL:** <https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475>\
**Category:** Logstash\
**Created:** [October 21, 2019, 1:03pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475 "2019-10-21T13:03:06Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marta\_Zagrajek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_zagrajek/32/47442_2.png) [@Marta\_Zagrajek](https://discuss.elastic.co/u/Marta_Zagrajek)\
**Post date:** [October 21, 2019, 1:03pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/1 "2019-10-21T13:03:06Z")

</div>

Hello there  
I have apache logs in which are documents that I want to remove **completely**.  
**Whole documents not fields** so I do not want to use remove\_field in mutate.  
I have tried drop:

```
filter {
      if "field_name" == "exact_value" {
        drop {}
      }
      } 

```

so it looked like this in final:

```
filter {
      if "url.original" == "/im/nagios.plc" {
        drop {}
      }
      } 

```

But it will not work, the documents are still there.  
I have also tried drop { } with space inside.  
I have tried [url.original] and [url.original] ==\>  
Logs of logstash will not show any problems.

I prefer not to create tags and then delete the documents with tags but if there will be no other way I will do it

Thank you for help!

---

<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 21, 2019, 1:11pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/2 "2019-10-21T13:11:13Z")

</div>

Is url.original a field with a period in its name, or is it a url object that contains an original field, in which case you should refer to it as [url][original] in logstash?

---

<div class="post-metadata">

**Author:** ![Marta\_Zagrajek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_zagrajek/32/47442_2.png) [@Marta\_Zagrajek](https://discuss.elastic.co/u/Marta_Zagrajek)\
**Post date:** [October 21, 2019, 1:17pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/3 "2019-10-21T13:17:36Z")

</div>

It is unfortunately field with period. That is why I finally chose to put it in " " instead of brackets.  
And for this particular value is exactly: /im/nagios.plc  
I did not know if REGEX will work, so I chose exact value.

---

<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 21, 2019, 1:33pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/4 "2019-10-21T13:33:44Z")

</div>

> [@Marta\_Zagrajek](#):
>
> if "url.original" == "/im/nagios.plc" { drop {} }

In that case I would expect that to work.

---

<div class="post-metadata">

**Author:** ![Marta\_Zagrajek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_zagrajek/32/47442_2.png) [@Marta\_Zagrajek](https://discuss.elastic.co/u/Marta_Zagrajek)\
**Post date:** [October 21, 2019, 1:40pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/5 "2019-10-21T13:40:26Z")

</div>

I restarted logstash, refreshed indexes. Nothing.  
Maybe I will wait till next index will be created and it will not have this documents?

---

<div class="post-metadata">

**Author:** ![Marta\_Zagrajek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_zagrajek/32/47442_2.png) [@Marta\_Zagrajek](https://discuss.elastic.co/u/Marta_Zagrajek)\
**Post date:** [October 22, 2019, 6:19pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/6 "2019-10-22T18:19:14Z")

</div>

I found the answer. The if statement was good, but I fixed my format of apache logs.

---

<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 19, 2019, 6:19pm UTC](https://discuss.elastic.co/t/remove-whole-documents-with-certain-value-in-field/204475/7 "2019-11-19T18:19:17Z")

</div>

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