# Manage dynamic fields type

**URL:** <https://discuss.elastic.co/t/manage-dynamic-fields-type/123599>\
**Category:** Logstash\
**Created:** [March 12, 2018, 5:02pm UTC](https://discuss.elastic.co/t/manage-dynamic-fields-type/123599 "2018-03-12T17:02:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![OptiFine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/optifine/32/26790_2.png) [@OptiFine](https://discuss.elastic.co/u/OptiFine)\
**Post date:** [March 12, 2018, 5:02pm UTC](https://discuss.elastic.co/t/manage-dynamic-fields-type/123599/1 "2018-03-12T17:02:47Z")

</div>

Hello,

I have in my input something like this :

```
[
hibernate.transaction.count=[10],
hibernate.flush.count=[9],
hibernate.entity0=[foo.foo.foo.Class],
hibernate.entity0.fetchcount=[2],
hibernate.entity1=[foo.foo.foo.Class],
hibernate.entity1.fetchcount=[1],
hibernate.entity2=[foo.foo.foo.Class],
hibernate.entity2.fetchcount=[5],
hibernate.entity3=[foo.foo.foo.Class],
hibernate.entity3.fetchcount=[2],
hibernate.entity4=[foo.foo.foo.Class],
hibernate.entity4.fetchcount=[1]
]

```

These values are extracted with a grok from the original message.

So I used a filter KV to extract all those keys

```
kv {
      source => "stats_hibernate"
      allow_duplicate_values => false
      field_split => ","
      include_brackets => true
      trim_value => "\t\s"
      remove_field => ["stats_hibernate"]
    }

```

And I encounter a problem :

```
16:39:03.072 [[main]>worker0] WARN logstash.outputs.elasticsearch - Could not index event to Elasticsearch. {
:status=>400, 
:action=>["index", 
{:_id=>"xxx", :_index=>"xxx-2018.03", :_type=>"logs", :_routing=>nil}, 
2018-03-12T14:29:30.991Z logstash %{message}], 
:response=>{"index"=>{"_index"=>"xxx-2018.03", "_type"=>"logs", "_id"=>"b7731767ddd1d27cc545e43bdcf91eb490aad1a3f24788e6ef7e206b57f63de1", 
"status"=>400, "error"=>{"type"=>"illegal_argument_exception", 
"reason"=>"Can't merge a non object mapping [hibernate.entity0] with an object mapping [hibernate.entity0]"}}}}

```

As the keys are dynamic I can't do a mutate filter because the regex is not implemented...

Do you have an idea of how I can overcome this problem ?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![OptiFine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/optifine/32/26790_2.png) [@OptiFine](https://discuss.elastic.co/u/OptiFine)\
**Post date:** [March 13, 2018, 2:11pm UTC](https://discuss.elastic.co/t/manage-dynamic-fields-type/123599/2 "2018-03-13T14:11:46Z")

</div>

I found that logstash create object fields when they have "." in their name.

Ex : "hibernate.entity0.name" will be inserted as :

```
hibernate {
    entity0 {
        name = ""
   }
} 

```

So in my case i renamed hibernate.entity#=[foo.foo.foo.Class] to hibernate.entity#.name=[foo.foo.foo.Class]

---

<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 10, 2018, 2:11pm UTC](https://discuss.elastic.co/t/manage-dynamic-fields-type/123599/3 "2018-04-10T14:11:51Z")

</div>

Closed on April 10, 2018, 2:11pm UTC

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