# Logstash is not taking in account whitespaces at the end of lines ? (grok filter)

**URL:** <https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449>\
**Category:** Logstash\
**Created:** [November 29, 2021, 3:34pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449 "2021-11-29T15:34:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![duanra22](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@duanra22](https://discuss.elastic.co/u/duanra22)\
**Post date:** [November 29, 2021, 3:34pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449/1 "2021-11-29T15:34:36Z")

</div>

Hello Elastic community,

Sorry if this question has already been asked but I didn't find something that was close to what I'm looking for.  
I'm new to logstash and I'm trying to use Grok filter.  
I have a string of concatenated data as : `data1data2data3data4`  
and I want to get each data into a new field :

```auto
{
  "value1": "data1",
   "value2": "data2",
   "value3": "data3",
   "value4": "data4",
}

```

And some data can be null.  
For example, if I have the following string `data1 data3 ` (with 5 whitespaces at the end of the string)  
(I know the length of each data, here it's 5 for all for the example)

And if I use the grok filter as `(?<value1>.{5})(?<value2>.{5})(?<value3>.{5})(?<value4>.{5})` the grok debugger says that the pattern does not match the input.  
However if I try to get only 3 values it works fine.

Does that mean that logstash does not take in account whitespaces at the end of a string and stops at the last character ? Should I add a character at the end of my line in order to get all data that I want ?  
Or is there a simple way to retrieve everything ?

Thank you for your time.

---

<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:** [November 29, 2021, 5:45pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449/2 "2021-11-29T17:45:54Z")

</div>

If you use

```
output { stdout { codec => rubydebug } }

```

then what does the [message] field loook like?

---

<div class="post-metadata">

**Author:** ![duanra22](https://avatars.discourse-cdn.com/v4/letter/d/3ec8ea/32.png) [@duanra22](https://discuss.elastic.co/u/duanra22)\
**Post date:** [December 1, 2021, 4:42pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449/3 "2021-12-01T16:42:41Z")

</div>

Hello Badger

It actually works on my logstash instance.  
To be clear, I was testing with the grok debugger in Kibana.  
Sorry for the inconvinience, I should have tested directly on my logstash instance.  
Still thank you for your time.  
This topic can be close

---

<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:** [December 29, 2021, 4:42pm UTC](https://discuss.elastic.co/t/logstash-is-not-taking-in-account-whitespaces-at-the-end-of-lines-grok-filter/290449/4 "2021-12-29T16:42:42Z")

</div>

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