# KV Whitespace Question

**URL:** <https://discuss.elastic.co/t/kv-whitespace-question/189400>\
**Category:** Logstash\
**Created:** [July 8, 2019, 5:58pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400 "2019-07-08T17:58:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![swiftingdarkness](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@swiftingdarkness](https://discuss.elastic.co/u/swiftingdarkness)\
**Post date:** [July 8, 2019, 5:58pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/1 "2019-07-08T17:58:53Z")

</div>

I am trying to figure out a way to either:

1. _Replace all spaces in the field with underscores_  
OR
2. _Capture the entire string with the spaces into the field._

Every solution that I have found does not work so far. I've looked throughout the documentation of the filter itself and the mutate filter as well.

**Sample**  **Log** :  
[REMARKS = An attempt was made to access an object.]

What the current output is:  
"remarks" =\> "An"

**Configuration** :

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

Please help. All is appreciated.

---

<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:** [July 8, 2019, 6:20pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/2 "2019-07-08T18:20:21Z")

</div>

> [@swiftingdarkness](#):
>
> [REMARKS = An attempt was made to access an object.]

I would not use kv for that. How about this?...

```
    dissect { mapping => { "message" => "[%{[@metadata][fieldname]} = %{[@metadata][fieldvalue]} ]" } }
    mutate { add_field => { "%{[@metadata][fieldname]}" => "%{[@metadata][fieldvalue]}" } }

```

---

<div class="post-metadata">

**Author:** ![swiftingdarkness](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@swiftingdarkness](https://discuss.elastic.co/u/swiftingdarkness)\
**Post date:** [July 8, 2019, 7:17pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/3 "2019-07-08T19:17:07Z")

</div>

Thank you for your reply.

I tried what you suggested and I did not do the trick. Is there a way to change the default delimiter of KV?

---

<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:** [July 8, 2019, 8:01pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/4 "2019-07-08T20:01:16Z")

</div>

> [@swiftingdarkness](#):
>
> Is there a way to change the default delimiter of KV?

Yes. Either field\_split or value\_split (or the \_pattern versions of these) depending on what you want to change

---

<div class="post-metadata">

**Author:** ![swiftingdarkness](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@swiftingdarkness](https://discuss.elastic.co/u/swiftingdarkness)\
**Post date:** [July 9, 2019, 1:34pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/5 "2019-07-09T13:34:26Z")

</div>

Okay, Ill give that a shot. Thank you.

Can I only do a single delimiter with kv or can I do multiple? Because I would have to capture fieldname between "[" and "=", then the field data between "=" and "]". As shown below

[SOURCE = XXX-XX-XX] [REMARKS = An attempt was made to access an object.]

Last time I appempted this, all of the fieldnames worked but the data within them was "][ ".

Thanks again.

---

<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:** [July 9, 2019, 1:58pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/6 "2019-07-09T13:58:32Z")

</div>

Read the [documentation](https://www.elastic.co/guide/en/logstash/current/plugins-filters-kv.html#plugins-filters-kv-field_split). It supports both multiple characters and regexps for both field and value delimiters.

---

<div class="post-metadata">

**Author:** ![swiftingdarkness](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@swiftingdarkness](https://discuss.elastic.co/u/swiftingdarkness)\
**Post date:** [July 9, 2019, 2:01pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/7 "2019-07-09T14:01:50Z")

</div>

I just got it to work! Thanks for your help. @Badger

---

<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:** [August 6, 2019, 2:01pm UTC](https://discuss.elastic.co/t/kv-whitespace-question/189400/8 "2019-08-06T14:01:55Z")

</div>

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