# Grok pattern DATA (.\*?) not giving all matches from the line

**URL:** <https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468>\
**Category:** Logstash\
**Created:** [July 18, 2018, 7:30am UTC](https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468 "2018-07-18T07:30:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![laxman1](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laxman1](https://discuss.elastic.co/u/laxman1)\
**Post date:** [July 18, 2018, 7:30am UTC](https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468/1 "2018-07-18T07:30:14Z")

</div>

Text : Beginning Master Job Beginning child1 Job Beginning child2 Job

when I used the below grok pattern temp variable is capturing only "Master" where as I need "child1" and "child2" matches also from text  
grok{

```
           patterns_dir => ["./patterns"]
           match => {"message" => "Beginning %{DATA:temp} Job"}
          break_on_match => false
    }

```

I made break\_on\_match false also

---

<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:** [July 18, 2018, 3:04pm UTC](https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468/2 "2018-07-18T15:04:15Z")

</div>

> [@laxman1](#):
>
> Beginning Master Job Beginning child1 Job Beginning child2 Job

I would use a ruby filter to scan that.

```
    ruby {
        code => "
            s = event.get('message')
            r = s.scan(/Beginning ([^[:space:]]+) Job/)
            r = r.flatten
            event.set('jobs', r.join(','))
        "
    }

```

You might then want to mutate+split the jobs field.

---

<div class="post-metadata">

**Author:** ![laxman1](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@laxman1](https://discuss.elastic.co/u/laxman1)\
**Post date:** [July 19, 2018, 12:55pm UTC](https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468/3 "2018-07-19T12:55:28Z")

</div>

Thanks for the reply. It is working for this but I have multiple patterns in such way. It would be nicer if it is taken care by grok filter.

---

<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:** [August 16, 2018, 12:55pm UTC](https://discuss.elastic.co/t/grok-pattern-data-not-giving-all-matches-from-the-line/140468/4 "2018-08-16T12:55:30Z")

</div>

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