# Logstash name fields

**URL:** <https://discuss.elastic.co/t/logstash-name-fields/49967>\
**Category:** Logstash\
**Created:** [May 13, 2016, 6:56am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967 "2016-05-13T06:56:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stefansaye](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@stefansaye](https://discuss.elastic.co/u/stefansaye)\
**Post date:** [May 13, 2016, 6:56am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967/1 "2016-05-13T06:56:07Z")

</div>

i have a field, the field format looks like

A-B-C::E\_[randomNum]  
the field is dynamic because the randonNUM , i want to change the '-' to '\_' and remove the [randomNUM] and it's will be looks like as follow,

A-B-C::E

Is there any plugin / strategy to solve this problem?  
any help will be appreciated !

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 13, 2016, 8:12am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967/2 "2016-05-13T08:12:29Z")

</div>

The mutate plugin will solve your problem, using regex replacement :

```
mutate {
  gsub => ["message", "_[0-9]+", "" ]
}

mutate {
  gsub => ["message", "[-]", "_" ]
}
```

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 13, 2016, 8:26am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967/4 "2016-05-13T08:26:20Z")

</div>

OK, so this pattern is "fieldname". I believed it was field value.

It is weird like field name.  
Is the original field name generated by logstash, or do you get it like that from an external source ?

If it is first option, I invite you to generate at the beginning the wished field name.  
Because, after, you can't do it without using ruby filter and write code which mutates event.

---

<div class="post-metadata">

**Author:** ![fbaligand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fbaligand/32/5657_2.png) [@fbaligand](https://discuss.elastic.co/u/fbaligand)\
**Post date:** [May 13, 2016, 9:46am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967/6 "2016-05-13T09:46:27Z")

</div>

OK.

It is weird like field name.  
Is the original field name generated by logstash, or do you get it like that from an external source ?

---

<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:** [July 6, 2017, 4:57am UTC](https://discuss.elastic.co/t/logstash-name-fields/49967/7 "2017-07-06T04:57:42Z")

</div>


