# Logstash grok pattern: Unexpected output

**URL:** <https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616>\
**Category:** Logstash\
**Created:** [May 29, 2018, 6:05am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616 "2018-05-29T06:05:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [May 29, 2018, 6:05am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/1 "2018-05-29T06:05:43Z")

</div>

Hello,

This is the sample log pattern I'm parsing. I'm using grok but it's not exactly as what I expected

`180528 8:46:26 2 Query	SELECT 1`

To parse this log my grok pattern is

`%{NUMBER:date} %{NOTSPACE:time}%{INT:pid}%{GREEDYDATA:message}`

and output for this in grok debugger is

```
{
  "date": [
    [
      "180528"
    ]
  ],
  "time": [
    [
      "8:46:2"
    ]
  ],
  "pid": [
    [
      "6"
    ]
  ],
  "message": [
    [
      " 2 Query\tSELECT 1"
    ]
  ]
}

```

If you observe in the output, pid is being extracted from time and actual pid which is 2 is being merged in the message. Not sure what went wrong here

Please help, Thanks for your time

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 29, 2018, 9:10am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/2 "2018-05-29T09:10:23Z")

</div>

You need spaces between your NOTSPACE, INT, and GREEDYDATA patterns.

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [May 29, 2018, 10:31am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/3 "2018-05-29T10:31:19Z")

</div>

@magnusbaeck

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/2/7/2761a07a670491fd8af30b4772ce7f7014aaa509.png)

Still I'm not able to make it

Any suggestions?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 29, 2018, 11:34am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/4 "2018-05-29T11:34:11Z")

</div>

There are two spaces between the timestamp and "2 Query". You can use `\s+` to match one or more whitespace characters.

---

<div class="post-metadata">

**Author:** ![rahulnama](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@rahulnama](https://discuss.elastic.co/u/rahulnama)\
**Post date:** [May 29, 2018, 11:48am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/5 "2018-05-29T11:48:25Z")

</div>

It worked 🙂

Thankyou much @magnusbaeck

---

<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 26, 2018, 11:48am UTC](https://discuss.elastic.co/t/logstash-grok-pattern-unexpected-output/133616/6 "2018-06-26T11:48:29Z")

</div>

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