# Conditional check grok and mutate a grok field

**URL:** <https://discuss.elastic.co/t/conditional-check-grok-and-mutate-a-grok-field/207895>\
**Category:** Logstash\
**Created:** [November 14, 2019, 12:54pm UTC](https://discuss.elastic.co/t/conditional-check-grok-and-mutate-a-grok-field/207895 "2019-11-14T12:54:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Incauto](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/incauto/32/60149_2.png) [@Incauto](https://discuss.elastic.co/u/Incauto)\
**Post date:** [November 14, 2019, 12:54pm UTC](https://discuss.elastic.co/t/conditional-check-grok-and-mutate-a-grok-field/207895/1 "2019-11-14T12:54:19Z")

</div>

Hi, I need to check if the first column of data " **os**" contains the string "lnx" or "win",

if contains the string " **lnx**" in the first column do this grok:  
grok { match =\> { "message" =\> "%{DATA: **os** }%{NUMBER: **virt\_mem\_used** }"} }

if contains the string " **win**" in the first column do this grok:  
grok { match =\> { "message" =\> "%{DATA: **os** }%{NUMBER: **swap\_space\_used** }"} }

Is this posible?

---

<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 12, 2019, 12:54pm UTC](https://discuss.elastic.co/t/conditional-check-grok-and-mutate-a-grok-field/207895/2 "2019-12-12T12:54:21Z")

</div>

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