# Logstash Filter - regez

**URL:** <https://discuss.elastic.co/t/logstash-filter-regez/263806>\
**Category:** Logstash\
**Created:** [February 9, 2021, 9:05pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806 "2021-02-09T21:05:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jancodenew](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@jancodenew](https://discuss.elastic.co/u/jancodenew)\
**Post date:** [February 9, 2021, 9:05pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806/1 "2021-02-09T21:05:02Z")

</div>

Hi,

Please help me with the if condition filter in logstash for same KQL querymentioned below.  
message: \*.url.\* and not \*failover\*

Below logstash filter is not working  
filter{  
if ([message] != ‘.\.url\..’ and [message] == ‘.failover.’)  
{  
grok{}  
}  
else{  
drop{}  
}  
}

---

<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:** [February 9, 2021, 9:08pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806/2 "2021-02-09T21:08:55Z")

</div>

Use a substring match

```
if ".url." in [message] and "failover" not in [message] {
```

---

<div class="post-metadata">

**Author:** ![jancodenew](https://avatars.discourse-cdn.com/v4/letter/j/87869e/32.png) [@jancodenew](https://discuss.elastic.co/u/jancodenew)\
**Post date:** [February 9, 2021, 9:28pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806/3 "2021-02-09T21:28:02Z")

</div>

Thank you @Badger for your reply.

Can you please tell me how can I use .url. with wildcard on both ends?, like this \*.url.\* in KQL.

---

<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:** [February 9, 2021, 9:33pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806/4 "2021-02-09T21:33:06Z")

</div>

`"something" in [message]` is a substring match. It does not need wildcards at each end, they are implicit.

---

<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:** [March 9, 2021, 9:33pm UTC](https://discuss.elastic.co/t/logstash-filter-regez/263806/5 "2021-03-09T21:33:09Z")

</div>

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