# Logstash drop filter plugin

**URL:** <https://discuss.elastic.co/t/logstash-drop-filter-plugin/320526>\
**Category:** Logstash\
**Created:** [December 6, 2022, 6:10am UTC](https://discuss.elastic.co/t/logstash-drop-filter-plugin/320526 "2022-12-06T06:10:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bex](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@bex](https://discuss.elastic.co/u/bex)\
**Post date:** [December 6, 2022, 6:10am UTC](https://discuss.elastic.co/t/logstash-drop-filter-plugin/320526/1 "2022-12-06T06:10:09Z")

</div>

As we know, we can drop like that:  
if [log][file][path] == "/var/log/messages" {  
drop {}  
}  
But I have case when I am getting logs in format "/var/log/messages-20221212" or "/var/log/messages-date"

But logstash drop filter plugin is not understanding:  
if [log][file][path] == "/var/log/messages-\*" {  
drop {}  
}  
Can anyone help me?  
Thanks

---

<div class="post-metadata">

**Author:** ![Rios](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rios/32/95745_2.png) [@Rios](https://discuss.elastic.co/u/Rios)\
**Post date:** [December 6, 2022, 7:19am UTC](https://discuss.elastic.co/t/logstash-drop-filter-plugin/320526/2 "2022-12-06T07:19:31Z")

</div>

Try with:

```auto
if ( [log][file][path] =~ /^\/var\/log\/messages-\d+/) {
  drop {}
}

```

You can also use without \d+ at the end in case you don't want a number validation, at the end.

---

<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:** [January 3, 2023, 7:19am UTC](https://discuss.elastic.co/t/logstash-drop-filter-plugin/320526/3 "2023-01-03T07:19:35Z")

</div>

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