# Keyword filter

**URL:** <https://discuss.elastic.co/t/keyword-filter/172344>\
**Category:** Logstash\
**Created:** [March 14, 2019, 1:44pm UTC](https://discuss.elastic.co/t/keyword-filter/172344 "2019-03-14T13:44:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexas](https://avatars.discourse-cdn.com/v4/letter/a/58956e/32.png) [@Alexas](https://discuss.elastic.co/u/Alexas)\
**Post date:** [March 14, 2019, 1:44pm UTC](https://discuss.elastic.co/t/keyword-filter/172344/1 "2019-03-14T13:44:55Z")

</div>

Configured in which there is an input and output file  
input  
{  
file  
{  
path =\> "/ home / sonic / log / vs01 / test\_new.log"  
start\_position =\> "beginning"  
ignore\_older =\> 0  
sincedb\_path =\> "/ dev / null"  
}}

output  
{  
file  
{  
path =\> "/ home / sonic / log / vs01 / test\_out.log"  
}}

We have several unnormalized logs (see example)  
You do not need to parse the logs, you need to find a line in which there are several keywords, for example: "F19021 out" and only write this word in the output file

How to do it?

Example log:  
: 50K: / 47  
IN08.PP770  
GRUPPm  
: 53B: / 3  
: 59: / 40  
IN77.PP773  
NTO  
m  
: 70: PO TU n49 OT 01.31.19G. V  
T.c. S (2.00): 14-44  
: 71A: OU  
F19021 out  
: 72: /RPP/27.1913.01  
/ DAS / 1900 + VP  
F19021  
-}  
[19/02/13 23:08:25] ID = esbBqSwMQ (info) [SwMQ.srv.WMQJMSSender] Initializing Converter Using default bean configuration .....  
[19/02/13 23:08:25] ID = esbBqSwMQ (info) [SwIMQ.srv.WMQJMSSender] Successful in sending message  
[19/02/13 23:08:25] {108: 00}} {4:  
: 20: + F19021 out  
: 23B: CR  
: 32A: 1900.00

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [March 14, 2019, 3:55pm UTC](https://discuss.elastic.co/t/keyword-filter/172344/2 "2019-03-14T15:55:25Z")

</div>

The logstash config language conditional logic syntax has support for regular expression test and negated regular expression test.

```auto
filter {
  if [message] !~ /F19021 out/ {
    drop {}
  }
}

```

---

<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:** [April 11, 2019, 3:55pm UTC](https://discuss.elastic.co/t/keyword-filter/172344/3 "2019-04-11T15:55:39Z")

</div>

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