# Logstah to parse only if matches the log

**URL:** <https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258>\
**Category:** Logstash\
**Created:** [January 22, 2019, 2:51pm UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258 "2019-01-22T14:51:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yazhini](https://avatars.discourse-cdn.com/v4/letter/y/e19adc/32.png) [@yazhini](https://discuss.elastic.co/u/yazhini)\
**Post date:** [January 22, 2019, 2:51pm UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258/1 "2019-01-22T14:51:46Z")

</div>

I have around 30+ error strings for docker logs. I need logstash to parse the logs only if it matches those error strings.

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 22, 2019, 3:19pm UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258/2 "2019-01-22T15:19:01Z")

</div>

It depends on what processing you want to do. You might be able to do this with a single grok that has 30+ patterns in it. Or you might need an if-else if-else if with 30+ branches.

---

<div class="post-metadata">

**Author:** ![yazhini](https://avatars.discourse-cdn.com/v4/letter/y/e19adc/32.png) [@yazhini](https://discuss.elastic.co/u/yazhini)\
**Post date:** [January 23, 2019, 4:06am UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258/3 "2019-01-23T04:06:58Z")

</div>

Thanks Badger for the reply, but how will parsing of fields works in this case. it's simple as like search, i don't want to parse it to any fields. I just want it to display the logs once it matches the error strings. Can you help me with the grok syntax for this?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 23, 2019, 1:04pm UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258/4 "2019-01-23T13:04:05Z")

</div>

Can you show me some examples of messages you want to index?

---

<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:** [February 20, 2019, 1:04pm UTC](https://discuss.elastic.co/t/logstah-to-parse-only-if-matches-the-log/165258/5 "2019-02-20T13:04:22Z")

</div>

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