# I want to put my grok inside if else block of logstash I want the fields to be displayed in kibana it's executing but not displaying the actual fields

**URL:** <https://discuss.elastic.co/t/i-want-to-put-my-grok-inside-if-else-block-of-logstash-i-want-the-fields-to-be-displayed-in-kibana-its-executing-but-not-displaying-the-actual-fields/333637>\
**Category:** Logstash\
**Created:** [May 17, 2023, 8:48am UTC](https://discuss.elastic.co/t/i-want-to-put-my-grok-inside-if-else-block-of-logstash-i-want-the-fields-to-be-displayed-in-kibana-its-executing-but-not-displaying-the-actual-fields/333637 "2023-05-17T08:48:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhir\_singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhir_singh/32/104889_2.png) [@sudhir\_singh](https://discuss.elastic.co/u/sudhir_singh)\
**Post date:** [May 17, 2023, 8:48am UTC](https://discuss.elastic.co/t/i-want-to-put-my-grok-inside-if-else-block-of-logstash-i-want-the-fields-to-be-displayed-in-kibana-its-executing-but-not-displaying-the-actual-fields/333637/1 "2023-05-17T08:48:56Z")

</div>

```auto
filter {
  if [IgmpSnooping] == "%IGMPSNOOPING-6-NO_IGMP_QUERIER" {
    grok { match => { "message" => "<%{INT:priority:int}>%{SYSLOGTIMESTAMP:timestamp}\s+%{HOSTNAME:device_name}\s+\IgmpSnooping:\s+%{DATA:IgmpSnooping}\:%{GREEDYDATA:message}" } }
  }
  else if [program] == "ConfigAgent" {
    grok { match => { "message" => "<%{POSINT:priority:int}>%{SYSLOGTIMESTAMP:timestamp} %{SYSLOGHOST:device_name} %{WORD:program}: %{DATA:message} sourceIP : \(%{IP:source_ip}\)" } }
  }
  
}

```

---

<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:** [June 14, 2023, 8:49am UTC](https://discuss.elastic.co/t/i-want-to-put-my-grok-inside-if-else-block-of-logstash-i-want-the-fields-to-be-displayed-in-kibana-its-executing-but-not-displaying-the-actual-fields/333637/2 "2023-06-14T08:49:08Z")

</div>

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