# How to drop event in logstash

**URL:** <https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854>\
**Category:** Logstash\
**Created:** [August 24, 2018, 7:07am UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854 "2018-08-24T07:07:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashok9177](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@ashok9177](https://discuss.elastic.co/u/ashok9177)\
**Post date:** [August 24, 2018, 7:07am UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854/1 "2018-08-24T07:07:58Z")

</div>

I want drop logfile mean shoudn't export to elasticsearch, like if any log message contains "monitoring" keyword i want to drop that event. can any anyone suggest me how to do that ?

```auto
filter {
  if [loglevel] == "debug" {
    drop { }
  }
}

```

The above example will drop the event when loglevel debug, but drop event when log message contains "monitoring" keyword

---

<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:** [August 24, 2018, 7:46am UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854/2 "2018-08-24T07:46:08Z")

</div>

```
if "monitoring" in [message] {
```

---

<div class="post-metadata">

**Author:** ![ashok9177](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@ashok9177](https://discuss.elastic.co/u/ashok9177)\
**Post date:** [August 24, 2018, 8:14am UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854/3 "2018-08-24T08:14:06Z")

</div>

@magnusbaeck thanks it worked. how to set 2 keywords?

example :

> if "monitoring" and " harvestor" in [message] {

---

<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:** [August 24, 2018, 2:19pm UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854/4 "2018-08-24T14:19:22Z")

</div>

```
if "x" in [message] and "y" in [message] {

```

You can also use a regular expression.

---

<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:** [September 21, 2018, 2:19pm UTC](https://discuss.elastic.co/t/how-to-drop-event-in-logstash/145854/5 "2018-09-21T14:19:28Z")

</div>

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