# Grok debugger works, on logstash not

**URL:** <https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930>\
**Category:** Logstash\
**Created:** [May 9, 2023, 12:38pm UTC](https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930 "2023-05-09T12:38:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![psyskeletor](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@psyskeletor](https://discuss.elastic.co/u/psyskeletor)\
**Post date:** [May 9, 2023, 12:38pm UTC](https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930/1 "2023-05-09T12:38:28Z")

</div>

Hi there.

Super new to logstash.  
I wanted to extract `exit code` from logs, so i came with this solution using grok debugger

```auto
filter {
     grok {
         match => { "message" => "(?<exit_code>\b[exit code]\d+ \b)" }
 
    }
}

```

but when running logstash locally with stdin with this line:

```auto
gitlab-runner-eks WARNING: Job failed: command terminated with exit code 1

```

it returns me this error:

```auto
gitlab-runner-eks WARNING: Job failed: command terminated with exit code 1
{
          "tags" => [
        [0] "_grokparsefailure"
    ],
      "@version" => "1",
       "message" => "gitlab-runner-eks WARNING: Job failed: command terminated with exit code 1",
          "host" => {
        "hostname" => "computer"
    },
         "event" => {
        "original" => "gitlab-runner-eks WARNING: Job failed: command terminated with exit code 1"
    },
    "@timestamp" => 2023-05-09T12:05:43.472221Z
}

```

Any ideas what i am doing wrong?

---

<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:** [May 9, 2023, 7:43pm UTC](https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930/2 "2023-05-09T19:43:08Z")

</div>

I would sugggest

```
grok { match => { "message" => "exit code (?<exit_code>\d+)" } }

```

Edited to add ... or even

```
grok { match => { "message" => "exit code %{INT:exit_code}" } }

```

---

<div class="post-metadata">

**Author:** ![psyskeletor](https://avatars.discourse-cdn.com/v4/letter/p/bbe5ce/32.png) [@psyskeletor](https://discuss.elastic.co/u/psyskeletor)\
**Post date:** [May 10, 2023, 8:23am UTC](https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930/3 "2023-05-10T08:23:54Z")

</div>

> [@Badger](#):
>
> `{ "message" => "exit code %{INT:exit_code}" }`

Worked like a charm!

thanks a lot!

---

<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:** [June 7, 2023, 8:24am UTC](https://discuss.elastic.co/t/grok-debugger-works-on-logstash-not/332930/4 "2023-06-07T08:24:31Z")

</div>

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