# Logstash filter with regex

**URL:** <https://discuss.elastic.co/t/logstash-filter-with-regex/225837>\
**Category:** Logstash\
**Created:** [March 31, 2020, 11:05am UTC](https://discuss.elastic.co/t/logstash-filter-with-regex/225837 "2020-03-31T11:05:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robo/32/38295_2.png) [@Robo](https://discuss.elastic.co/u/Robo)\
**Post date:** [March 31, 2020, 11:05am UTC](https://discuss.elastic.co/t/logstash-filter-with-regex/225837/1 "2020-03-31T11:05:20Z")

</div>

We are using following filter condition to distinguish if the value of a field is a string or an object:

```auto
  if [log][outgoing_message][body] =~ /.*/ {
    mutate {
       rename => ["[log][outgoing_message][body]", "[log][outgoing_message][body_text]"]
    }
  }

```

Is works pretty good, unless the value of the field is a number. in such case, the number does not met the regular expression and the field is not renamed. This leads to mapping issues at the end.  
e.g.  
`log.outgoing_message.body: 95456789 `

Is this a correct behavior of the logstash filter ?

---

<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 28, 2020, 11:05am UTC](https://discuss.elastic.co/t/logstash-filter-with-regex/225837/2 "2020-04-28T11:05:31Z")

</div>

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