logstash-input-mongodb icon indicating copy to clipboard operation
logstash-input-mongodb copied to clipboard

array not stored to elasticsearch

Open sulthonzh opened this issue 7 years ago • 13 comments

nested fields

Hi guys, i have a problem, for stored array from mongodb to elasticsearch (picture above), fields with array type not store to elasticsearch why? have set a config?

sulthonzh avatar Mar 27 '17 16:03 sulthonzh

Any update on this? It seems that arrays are not supported at all. Flattening seems to be working only for objects (arrays are ignored)

medianjoe avatar May 05 '17 22:05 medianjoe

Any update on this? I have many arrays with two float elements in my MongoDB. When they came to Kibana, all my arrays became [0, 0].

TaurusD avatar Jul 11 '17 09:07 TaurusD

hey guys, I come again for a similar shot. I tried to import some Array type data from mongo to elasticsearch. the arrays look like [{a:"bla",b:blabla"},{a:"bla",b:blabla"},{a:"bla",b:blabla"}], but they are not stored in any field in elasticsearch.

TaurusD avatar Aug 15 '17 02:08 TaurusD

Hi, I have the same problem. The other issue is that I want to handle the array by myself but it seems the plugin does not store the array in the next logstash pipeline (the filter stage after mongo input). A work-around would be highly appreciated

ivancruzbht avatar Oct 23 '17 22:10 ivancruzbht

I worked my way through this issue. I had to use a custom ruby filter to extract the array from the log_entry field that this plugin stores in elasticsearch, extract the array from it, and save each array item as a new field. In my case, the array is a root-level field called "messages", here is my code in case someone finds this issue again:

ruby {
        code => "
        @log_entry_hash = eval(event.get('log_entry'))
        counter = 0
        @log_entry_hash['messages'].to_a.each {|log|
              event.set('message' + counter.to_s, log)
              counter += 1
        }
        "
}

ivancruzbht avatar Oct 24 '17 19:10 ivancruzbht

Hi , can someone provide a demo of config file in logstash to send data from mongodb to logstash to store in ES ?
i downloaded the logstash-mongodb connector .

aki83reo avatar Dec 14 '17 06:12 aki83reo

@phutchins Do you think this issue would be resolved by https://github.com/phutchins/logstash-input-mongodb/pull/64 ?

ghost avatar Dec 30 '17 23:12 ghost

@phutchins I am also facing the same challenge when i am trying to port array type of date from mongodb to elastic. Anybody knows the solution for this.

potham avatar Dec 11 '18 08:12 potham

Anybody knows the solution for this issue?

codjust avatar May 16 '19 03:05 codjust

Problem still existed. But the data is persisted in "log_entry" field.

kychanbp avatar Nov 16 '19 04:11 kychanbp

I already have this problem with object and array lists while pushing data from mongodb to elasticsearch with logstash. this problem has not been solved yet with rubby filter. someone help me

mostaqimi avatar May 25 '20 01:05 mostaqimi

I worked my way through this issue. I had to use a custom ruby filter to extract the array from the log_entry field that this plugin stores in elasticsearch, extract the array from it, and save each array item as a new field. In my case, the array is a root-level field called "messages", here is my code in case someone finds this issue again:

ruby {
        code => "
        @log_entry_hash = eval(event.get('log_entry'))
        counter = 0
        @log_entry_hash['messages'].to_a.each {|log|
              event.set('message' + counter.to_s, log)
              counter += 1
        }
        "
}

Worked perfectly for my arrays! Change 'messages' to the array in question and it splits them.

diaztech avatar Oct 04 '21 19:10 diaztech

Thank you for this , its worked

brijesh-2203 avatar Jul 18 '22 09:07 brijesh-2203