Manage dynamic fields type

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.

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]

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