# Handle space in a field

**URL:** <https://discuss.elastic.co/t/handle-space-in-a-field/328190>\
**Category:** Logstash\
**Created:** [March 21, 2023, 5:35pm UTC](https://discuss.elastic.co/t/handle-space-in-a-field/328190 "2023-03-21T17:35:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubhamra](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rubhamra](https://discuss.elastic.co/u/rubhamra)\
**Post date:** [March 21, 2023, 5:35pm UTC](https://discuss.elastic.co/t/handle-space-in-a-field/328190/1 "2023-03-21T17:35:13Z")

</div>

I am trying to remove a space from a field in logstash but it's not working, because there is space in the field, I can't even rename the field or not able to do replacement is with gsub.

Request ID to be renamed to Request\_ID to use this field as document id in output filter. please help, thank you

```auto
  mutate {
        gsub => ["[response][body][values][Request ID]", ' ', "_" ]
    }

```

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [March 21, 2023, 5:56pm UTC](https://discuss.elastic.co/t/handle-space-in-a-field/328190/2 "2023-03-21T17:56:53Z")

</div>

Gsub does not works on fields names, only on the values that are stored in the fields.

Have you tried using `rename` to rename the field?

```auto
mutate {
    rename => {
        "[response][body][values][Request ID]" => "[response][body][values][Request_ID]"
    }
}

```

---

<div class="post-metadata">

**Author:** ![rubhamra](https://avatars.discourse-cdn.com/v4/letter/r/858c86/32.png) [@rubhamra](https://discuss.elastic.co/u/rubhamra)\
**Post date:** [March 21, 2023, 7:43pm UTC](https://discuss.elastic.co/t/handle-space-in-a-field/328190/3 "2023-03-21T19:43:41Z")

</div>

Its working now, I don't know I was doing the same but couldn't do it. might be using wrong braces.

Thanks, really appreciate..

---

<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:** [April 18, 2023, 7:44pm UTC](https://discuss.elastic.co/t/handle-space-in-a-field/328190/4 "2023-04-18T19:44:21Z")

</div>

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