# Grok pattern matching in debugger but not on logstash

**URL:** <https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624>\
**Category:** Logstash\
**Created:** [June 8, 2022, 4:25am UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624 "2022-06-08T04:25:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![smtp\_server](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smtp_server/32/102266_2.png) [@smtp\_server](https://discuss.elastic.co/u/smtp_server)\
**Post date:** [June 8, 2022, 4:25am UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624/1 "2022-06-08T04:25:21Z")

</div>

Obvious from question, I've been trying to look for fault for so long but still don't seem to be coming around solution. Here's config

```auto
filter{
grok{
pattern_definitions => {
        "CUSTOMMONTH" => "(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"
        "CUSTOMTIMESTAMP" => "%{MONTHDAY}/%{CUSTOMMONTH}/%{YEAR} %{TIME}"
    }
match=>{
    
    
    "message" => ["%{CUSTOMTIMESTAMP:time}",
           "\"%{WORD:method} %{DATA:url} HTTP"]
    "@version" => "%{NUMBER:num}"
    
}
add_field=>{"user"=>"url1" }

}
}

```

> "message" =\> "{"log":"[08/Jun/2022 03:29:16] "GET /cart/ HTTP/1.1" 200 16123\n","stream":"stderr","time":"2022-06-08T03:29:16.583783858Z"}"

Matches well on online debugger and ignore @version matching part because that works well.

---

<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:** [June 8, 2022, 4:37am UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624/2 "2022-06-08T04:37:02Z")

</div>

If your problem is that `"\"%{WORD:method} %{DATA:url} HTTP"` never matches (please do not make us guess) then look at the break\_on\_match option.

---

<div class="post-metadata">

**Author:** ![smtp\_server](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/smtp_server/32/102266_2.png) [@smtp\_server](https://discuss.elastic.co/u/smtp_server)\
**Post date:** [June 8, 2022, 8:22am UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624/4 "2022-06-08T08:22:25Z")

</div>

Sorry, I tried your method and it worked. I don't seem to get it however that how @version is matched first even though its position in event and same of its pattern in config file is after message

---

<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:** [June 8, 2022, 3:44pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624/5 "2022-06-08T15:44:57Z")

</div>

The options are a hash, and Java hashes are not ordred. There is no such thing as before or after.

---

<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:** [July 6, 2022, 3:45pm UTC](https://discuss.elastic.co/t/grok-pattern-matching-in-debugger-but-not-on-logstash/306624/6 "2022-07-06T15:45:17Z")

</div>

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