# Use kv filter on newline & return split pattern

**URL:** <https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655>\
**Category:** Logstash\
**Created:** [September 23, 2020, 12:12pm UTC](https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655 "2020-09-23T12:12:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ParashB](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@ParashB](https://discuss.elastic.co/u/ParashB)\
**Post date:** [September 23, 2020, 12:12pm UTC](https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655/1 "2020-09-23T12:12:32Z")

</div>

Hi, I am trying to use kv filter to parse the below logs

Name: abc\r\nAge: 39\r\nGender: Male\r\nSalary: 87

My kv filter is as below  
kv {  
source =\> "log"  
field\_split\_pattern =\> "\\\r\\\n"  
value\_split =\> ":"  
}

I have tried with different field\_split\_pattern as \r\n, \\r\\n & \\\r\\\n but nothing seems to split the key value pairs.

---

<div class="post-metadata">

**Author:** ![grumo35](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grumo35/32/59451_2.png) [@grumo35](https://discuss.elastic.co/u/grumo35)\
**Post date:** [September 23, 2020, 12:34pm UTC](https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655/2 "2020-09-23T12:34:46Z")

</div>

Hi,

In your filter you could replace all those \\r\\n with spaces usin the gsub processor

```auto
gsub => ["log","\\\r\\\n"," "]

kv { 
source => "log"
value_split => ":"
}
```

---

<div class="post-metadata">

**Author:** ![ParashB](https://avatars.discourse-cdn.com/v4/letter/p/b2d939/32.png) [@ParashB](https://discuss.elastic.co/u/ParashB)\
**Post date:** [September 30, 2020, 5:39am UTC](https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655/3 "2020-09-30T05:39:56Z")

</div>

Thank you @grumo35. That worked perfectly.

---

<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:** [October 28, 2020, 5:40am UTC](https://discuss.elastic.co/t/use-kv-filter-on-newline-return-split-pattern/249655/4 "2020-10-28T05:40:02Z")

</div>

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