# Logstash grok IF condition fields

**URL:** <https://discuss.elastic.co/t/logstash-grok-if-condition-fields/236561>\
**Category:** Logstash\
**Created:** [June 10, 2020, 5:58pm UTC](https://discuss.elastic.co/t/logstash-grok-if-condition-fields/236561 "2020-06-10T17:58:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![himalc](https://avatars.discourse-cdn.com/v4/letter/h/258eb7/32.png) [@himalc](https://discuss.elastic.co/u/himalc)\
**Post date:** [June 10, 2020, 5:58pm UTC](https://discuss.elastic.co/t/logstash-grok-if-condition-fields/236561/1 "2020-06-10T17:58:35Z")

</div>

Hi,  
Please let me know, following if condition can run for any docker images. I want to filter postgres-1 docker image logs only. What are those values ([docker][container][labels] ) How can I create this type of filter fields. Please explain this if possible.

filter {  
if **[docker][container][labels]** == "postgresql-1" {  
grok {  
pattern\_definitions =\> { patterns goes here..... }  
}  
}  
}

---

<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:** [July 8, 2020, 5:58pm UTC](https://discuss.elastic.co/t/logstash-grok-if-condition-fields/236561/2 "2020-07-08T17:58:37Z")

</div>

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