# Grok filter not working with if condition

**URL:** <https://discuss.elastic.co/t/grok-filter-not-working-with-if-condition/157475>\
**Category:** Logstash\
**Created:** [November 20, 2018, 6:21am UTC](https://discuss.elastic.co/t/grok-filter-not-working-with-if-condition/157475 "2018-11-20T06:21:52Z")\
**Posts on this page:** 2\
**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:** [November 20, 2018, 6:21am UTC](https://discuss.elastic.co/t/grok-filter-not-working-with-if-condition/157475/1 "2018-11-20T06:21:53Z")

</div>

```
> filter {
> if "id4444" in [fields][component] {
> grok {
> match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} (\[%{WORD:loglevel}\]) %{DATA} - %{DATA:method} processing time for transactionId : %{S3_REQUEST_LINE:transactionid} documentType : %{WORD:document type} is %{INT:duration:int}" }
> 
> match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} (\[%{WORD:loglevel}\]) %{DATA} - %{DATA:method} processing time for transactionId : %{S3_REQUEST_LINE:transactionid} documentType : %{WORD:document type} merchant : %{HOSTNAME:merchant} is %{INT:duration:int}" }
> 
> 
> match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} \[%{WORD:loglevel}\] %{GREEDYDATA}" }
> }
> }
> else if "idt.512" or "idt.256" in [fields][component] {
> grok {
> 
> match => ["message", "%{TIMESTAMP_ISO8601:timestamp} %{NUMBER} (\[%{WORD:loglevel}\])" ]
> }
> }
> else if "id2fa" in [fields][component] {
> grok {
> 
> match => ["message", "%{TIMESTAMP_ISO8601:timestamp} %{NUMBER} (\[%{WORD:loglevel}\])" ]
> }
> }
> else if "ida" in [fields][component] {
> grok {
> 
> match => ["message", "%{TIMESTAMP_ISO8601:timestamp} %{WORD:loglevel}"]
> }
> }

```

all grok filters are working but last if condtion filter isn't , is there any problem if condition ?

---

<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:** [December 18, 2018, 6:28am UTC](https://discuss.elastic.co/t/grok-filter-not-working-with-if-condition/157475/2 "2018-12-18T06:28:30Z")

</div>

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