# Trying to add prefix to key in logstash config, but without period

**URL:** <https://discuss.elastic.co/t/trying-to-add-prefix-to-key-in-logstash-config-but-without-period/74350>\
**Category:** Logstash\
**Created:** [February 8, 2017, 9:38am UTC](https://discuss.elastic.co/t/trying-to-add-prefix-to-key-in-logstash-config-but-without-period/74350 "2017-02-08T09:38:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LoriG](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@LoriG](https://discuss.elastic.co/u/LoriG)\
**Post date:** [February 8, 2017, 9:38am UTC](https://discuss.elastic.co/t/trying-to-add-prefix-to-key-in-logstash-config-but-without-period/74350/1 "2017-02-08T09:38:35Z")

</div>

From a component I am working on, I get certain information in the log that is report information. This information comes as "ReportBody". However, I want to add a prefix to some of the information (i.e. NumberOfDevices} from ReportBody so it appears that way in Kibana. Therefore, in my logstash configuration, I have written:

json {  
source =\> "ReportBody"  
target =\> "someReport"  
remove\_field =\> ["ReportBody"]  
}

The result in Kibana is "someReport.NumberofDevices": 3  
This includes period between the target(prefix) and the key. What can I do to "mutate" it so that either the period is deleted or I can substitute it with underscore ("\_")?

---

<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:** [February 8, 2017, 10:40am UTC](https://discuss.elastic.co/t/trying-to-add-prefix-to-key-in-logstash-config-but-without-period/74350/2 "2017-02-08T10:40:34Z")

</div>

The ruby filter example in this post is pretty close to what you need: [http://stackoverflow.com/a/28368575/414355](http://stackoverflow.com/a/28368575/414355)

If you run Logstash 5 or later you need to use the new event API, but that's a simple conversion of the code above.

---

<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:** [March 8, 2017, 10:40am UTC](https://discuss.elastic.co/t/trying-to-add-prefix-to-key-in-logstash-config-but-without-period/74350/3 "2017-03-08T10:40:45Z")

</div>

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