# Doesn't work when trying to match on "source" and "message" in the same grok

**URL:** <https://discuss.elastic.co/t/doesnt-work-when-trying-to-match-on-source-and-message-in-the-same-grok/212353>\
**Category:** Logstash\
**Created:** [December 18, 2019, 3:10pm UTC](https://discuss.elastic.co/t/doesnt-work-when-trying-to-match-on-source-and-message-in-the-same-grok/212353 "2019-12-18T15:10:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamish1](https://avatars.discourse-cdn.com/v4/letter/h/6f9a4e/32.png) [@Hamish1](https://discuss.elastic.co/u/Hamish1)\
**Post date:** [December 18, 2019, 3:10pm UTC](https://discuss.elastic.co/t/doesnt-work-when-trying-to-match-on-source-and-message-in-the-same-grok/212353/1 "2019-12-18T15:10:25Z")

</div>

Good day everyone!

I'm using filebeat and logstash.

Here is the part of logstash filter which is not working as I'm expecting.

```
if "app_name" in [tags] {

mutate {
    gsub => ["message", "\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]", ""]
  }

  grok {
     match => [
                "source" => "/opt/data/app/logs/%{GREEDYDATA:service_name}/%{GREEDYDATA:log_file_name}",
                "message" => "\[%{GREEDYDATA:severity}\] %{TIMESTAMP_ISO8601:timestamp} - %{GREEDYDATA:message}"
              ]
       overwrite => ["message"]
       }

  date {
    match => ["timestamp", "yyyy-mm-dd HH:mm:ss"]
    target => "@timestamp"
    timezone => "UTC"
    remove_field => ["timestamp"]
  }
}

```

As you can see, I'm trying to match and extract values from "source" field and "message" field in the same grok. But works only the first one (in this example - "source").

Is there a way how to achieve that?

Any help will be extremely appreciated!

---

<div class="post-metadata">

**Author:** ![Transrian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/transrian/32/58436_2.png) [@Transrian](https://discuss.elastic.co/u/Transrian)\
**Post date:** [December 19, 2019, 6:24pm UTC](https://discuss.elastic.co/t/doesnt-work-when-trying-to-match-on-source-and-message-in-the-same-grok/212353/2 "2019-12-19T18:24:11Z")

</div>

By default, Grok stop after the first match successful, which mean that if first parsing is successful (_source_), _message_ parsing will not be 'invoqued'.

To allow it to match your multiple fields / formats, you will need to disable the option [break\_on\_match](https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#plugins-filters-grok-break_on_match)

---

<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:** [January 16, 2020, 6:24pm UTC](https://discuss.elastic.co/t/doesnt-work-when-trying-to-match-on-source-and-message-in-the-same-grok/212353/3 "2020-01-16T18:24:12Z")

</div>

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