# Grokking works in debugger but differs in Logstash

**URL:** <https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793>\
**Category:** Logstash\
**Created:** [August 26, 2019, 2:22pm UTC](https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793 "2019-08-26T14:22:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveenrt23](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@naveenrt23](https://discuss.elastic.co/u/naveenrt23)\
**Post date:** [August 26, 2019, 2:22pm UTC](https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793/1 "2019-08-26T14:22:20Z")

</div>

Hello,

I'm using a regex which would remove the first word and parse the rest.

```
grok {
     match => { "resource" => "/[^/]+(/|)(?<repo>[^/]+)?(/%{GREEDYDATA:resource_path})?" }
      }

```

Test Messages:

- /list/Lighter-test-group/xyz/123
- /list/
- /list

I've been using [https://grokdebug.herokuapp.com/](https://grokdebug.herokuapp.com/) and [https://regex101.com/](https://regex101.com/) to test my regex and grok filter.

For messages,

- /list/Lighter-test-group/xyz/123 gives us repo value as " **Lighter-test-group**" which is valid
- /list/ gives us repo value as **null** which is valid

but /list gives repo value as " **list**" which is an invalid value. The correct value needs to be empty or null.

The sites I used for debugging gives me null values for /list but when I run Logstash locally, I see the value as "list". Does anyone know why there's a difference running locally vs using debuggers?

---

<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:** [August 26, 2019, 2:36pm UTC](https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793/2 "2019-08-26T14:36:03Z")

</div>

> [@naveenrt23](#):
>
> Does anyone know why there's a difference running locally vs using debuggers?

They are different code bases supported by different organizations. I would not expect them to stay in sync.

If you want to test grok filters then I would recommend that you do it using grok. Use two windows. In one run logstash with -r on the command line, so that it restarts the pipeline every time the configuration is modified. In the other edit the configuration. I would start with something like either

```
input { generator { count => 1 lines => ['/list/Lighter-test-group/xyz/123', "/list"] } }
filter {
    grok { match => { "message" => "..." } }
}
output { stdout { codec => rubydebug { metadata => false } } }

```

or

```
input { file { path => "/home/foo.txt" sincedb_path => "/dev/null" start_position => beginning }
filter {
    grok { match => { "message" => "..." } }
}
output { stdout { codec => rubydebug { metadata => false } } }

```

---

<div class="post-metadata">

**Author:** ![naveenrt23](https://avatars.discourse-cdn.com/v4/letter/n/47e85d/32.png) [@naveenrt23](https://discuss.elastic.co/u/naveenrt23)\
**Post date:** [August 26, 2019, 2:48pm UTC](https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793/3 "2019-08-26T14:48:11Z")

</div>

Thanks for the info.

I've been trying to get the right regex for the above scenario. Any help would be appreciated!

---

<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:** [September 23, 2019, 2:55pm UTC](https://discuss.elastic.co/t/grokking-works-in-debugger-but-differs-in-logstash/196793/4 "2019-09-23T14:55:48Z")

</div>

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