# Logstash Grep and Drop

**URL:** <https://discuss.elastic.co/t/logstash-grep-and-drop/35313>\
**Category:** Logstash\
**Created:** [November 23, 2015, 2:53pm UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313 "2015-11-23T14:53:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jackal9301](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jackal9301/32/5748_2.png) [@Jackal9301](https://discuss.elastic.co/u/Jackal9301)\
**Post date:** [November 23, 2015, 2:53pm UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313/1 "2015-11-23T14:53:15Z")

</div>

> [@Grep in logstash](https://discuss.elastic.co/t/grep-in-logstash/24510/2):
>
> Don't use the obsolete grep filter; use [conditionals](https://www.elastic.co/guide/en/logstash/current/configuration.html#conditionals) instead, e.g. like this to delete all messages where the foo field isn't equal to "bar": if [foo] != "bar" { drop { } }

## I have an old conf file my predecessor made with grep in it for logstash. Under that is the Drop command. What can I use as the equivalent to make it still work the same way?

if [SourceModuleName] == 'eftxferlogs' {

```
    grok {
        match => ['message', '%{TIMESTAMP_ISO8601:EventTime} %{IPORHOST:FTPClientIpAddress} - %{NOTSPACE:FTPUserName} %{NAGIOSTIME}(?<FTPCommand>%{WORD} %{NOTSPACE}) - %{NOTSPACE:FTPStatusCode} %{NOTSPACE:FTPDownloadedBytes} %{NOTSPACE:FTPUploadedBytes} %{NOTSPACE:FTPServerIP} %{NOTSPACE:FTPServerPort}']
    }

    date {
        match => ['EventTime', 'YYYY-MM-dd HH:mm:ss']
        timezone => 'UTC'
    }

    dns {
        reverse => ['host']
        action => 'replace'
    }

    # Tag all sent/downloaded files
    #
    grep {
        match => ['FTPCommand', '^sent.*$']
        add_tag => 'sent_file'
        drop => 'false'
    }

```

Is the Drop command the same as break\_on\_match?

Instead of using grep in the old config which is obviously broken since I updated logstash I need to find something that will serve the same purpose.

Thanks,  
Jack

---

<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:** [November 23, 2015, 3:23pm UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313/2 "2015-11-23T15:23:03Z")

</div>

```auto
if [FTPCommand] =~ /^send.*$/ {
  mutate {
    add_tag => 'sent_file'
  }
}

```

---

<div class="post-metadata">

**Author:** ![Jackal9301](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jackal9301/32/5748_2.png) [@Jackal9301](https://discuss.elastic.co/u/Jackal9301)\
**Post date:** [November 23, 2015, 3:31pm UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313/3 "2015-11-23T15:31:58Z")

</div>

replace the grep portion with this?

---

<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:** [November 24, 2015, 6:52am UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313/4 "2015-11-24T06:52:25Z")

</div>

Yes, that's right.

---

<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:21am UTC](https://discuss.elastic.co/t/logstash-grep-and-drop/35313/5 "2017-07-06T05:21:37Z")

</div>


