# Logstash grok matches on two different fields log\_type and message

**URL:** <https://discuss.elastic.co/t/logstash-grok-matches-on-two-different-fields-log-type-and-message/103077>\
**Category:** Logstash\
**Created:** [October 6, 2017, 8:38pm UTC](https://discuss.elastic.co/t/logstash-grok-matches-on-two-different-fields-log-type-and-message/103077 "2017-10-06T20:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajstark123](https://avatars.discourse-cdn.com/v4/letter/a/73ab20/32.png) [@ajstark123](https://discuss.elastic.co/u/ajstark123)\
**Post date:** [October 6, 2017, 8:38pm UTC](https://discuss.elastic.co/t/logstash-grok-matches-on-two-different-fields-log-type-and-message/103077/1 "2017-10-06T20:38:57Z")

</div>

We are using file beat to read multiple logs and we are send the output to logstash. We want a logstash grok filter to activate when (log\_type == syslog) and (matches on syslog message)

grok {  
match =\> {"log\_type" =\> "syslog" }  
# every thing below this lines work for syslog. The line above is new  
match =\> { "message" =\> "%{SYSLOGTIMESTAMP:syslog\_timestamp} %{SYSLOGHOST:syslog\_hostname} %{DATA:syslog\_program}(?:[%{POSINT:syslog\_pid}])?: %{GREEDYDATA:syslog\_message}" }  
add\_field =\> ["received\_at", "%{@timestamp}"]  
add\_field =\> ["received\_from", "%{host}"]  
}  
date {  
match =\> ["syslog\_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss"]  
}

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 10, 2017, 6:29pm UTC](https://discuss.elastic.co/t/logstash-grok-matches-on-two-different-fields-log-type-and-message/103077/2 "2017-10-10T18:29:24Z")

</div>

Wrap your grok filter in a conditional.

[https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html](https://www.elastic.co/guide/en/logstash/current/event-dependent-configuration.html)

---

<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 7, 2017, 6:30pm UTC](https://discuss.elastic.co/t/logstash-grok-matches-on-two-different-fields-log-type-and-message/103077/3 "2017-11-07T18:30:14Z")

</div>

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