# Configure Grok Filters

**URL:** <https://discuss.elastic.co/t/configure-grok-filters/152169>\
**Category:** Logstash\
**Created:** [October 12, 2018, 6:44am UTC](https://discuss.elastic.co/t/configure-grok-filters/152169 "2018-10-12T06:44:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shirm](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@shirm](https://discuss.elastic.co/u/shirm)\
**Post date:** [October 12, 2018, 6:44am UTC](https://discuss.elastic.co/t/configure-grok-filters/152169/1 "2018-10-12T06:44:07Z")

</div>

Hi All, I am just starting out with Logstash.  
I am trying to parse a logfile with error contents as

```
2018-09-03 15:31:51.9682 Error ActiveDirectory Application MyApp is referenced by groups uADGROUP1 and uADGROUP2 - only permissions for uADGROUP1 will apply

```

I have written a logstash config as below

```
# contents of logstash\bin\logstash.config

# input
input {
file {
    path => "C:\DATA\packagepromoterdata\diagnostics\ActiveDirectoryTest.log"
    start_position => beginning        
    }
}

filter {
grok {
    match => { "message" => "Error\sActiveDirectory\sApplication\s%{WORD:App_Name}\sis\sreferenced\sby\sgroups\s%{WORD:AD_Group1}\sand\s%{WORD:AD_Group2}\s-\sonly\spermissions\sfor\s%{WORD:ADGroup_Apply}\swill\sapply"}        
    }
}

output {
  stdout { }
}

```

I have tried this filter in Grok Debugger: [http://grokdebug.herokuapp.com/](http://grokdebug.herokuapp.com/) and confirmed that this filter works, however while trying it in the config file, all the entries in the log entries are getting displayed

---

<div class="post-metadata">

**Author:** ![AquaX](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aquax/32/92006_2.png) [@AquaX](https://discuss.elastic.co/u/AquaX)\
**Post date:** [October 12, 2018, 3:11pm UTC](https://discuss.elastic.co/t/configure-grok-filters/152169/2 "2018-10-12T15:11:16Z")

</div>

If your grok pattern does not match what you want then you should drop the message.  
Add this line after your grok filter inside the filter{} section

```
if "_grokparsefailure" in [tags] {
drop {}
}

```

Should look like this:

```
# contents of logstash\bin\logstash.config

# input
input {
file {
    path => "C:\DATA\packagepromoterdata\diagnostics\ActiveDirectoryTest.log"
    start_position => beginning        
    }
}

filter {
grok {
          match => { "message" => "Error\sActiveDirectory\sApplication\s%{WORD:App_Name}\sis\sreferenced\sby\sgroups\s%{WORD:AD_Group1}\sand\s%{WORD:AD_Group2}\s-\sonly\spermissions\sfor\s%{WORD:ADGroup_Apply}\swill\sapply"}        
    }

    if "_grokparsefailure" in [tags] {
          drop {}
    }
}

output {
  stdout { }
}
```

---

<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:** [November 9, 2018, 3:24pm UTC](https://discuss.elastic.co/t/configure-grok-filters/152169/3 "2018-11-09T15:24:03Z")

</div>

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