elasticsearch - Logstash - how do I split an array using the split filter without a target? -


i'm trying split json array multiple events. here's sample input:

{"results" : [{"id": "a1", "name": "hello"}, {"id": "a2", "name": "logstash"}]} 

here's filter , output config:

filter {   split {     field => "results"   } } stdout {    codec => "rubydebug" } 

this produces 2 events, 1 each of jsons in array. , it's close i'm looking for:

{                                                      "results" => {                                     "id" => "a1",                                 "name" => "hello"                           },                                                "@version" => "1",                            "@timestamp" => "2015-05-30t18:33:21.527z",           "host" => "laptop",                                       }                                               {                                                      "results" => {                                     "id" => "a2",                                 "name" => "logstash"                        },                                                "@version" => "1",                            "@timestamp" => "2015-05-30t18:33:21.527z",           "host" => "laptop",                                    } 

the problem nested "results" part. "results" being default value target parameter. there way use split filter without producing nested json, , this:

{                                                                                "id" => "a1",                                 "name" => "hello"                             "@version" => "1",                            "@timestamp" => "2015-05-30t18:33:21.527z",           "host" => "laptop",                                       }                                               {                                                         "id" => "a2",                                 "name" => "logstash"                          "@version" => "1",                            "@timestamp" => "2015-05-30t18:33:21.527z",           "host" => "laptop",                                    } 

the purpose feed elasticsearch output each event being document document_id => "id". solutions welcomed!

if know of fields (as appears do), can rename fields:

    mutate {             rename => [                     "[results][id]", "id",                     "[results][name]", "name"             ]             remove_field => "results"     } 

if didn't know of fields were, write ruby code filter did event['results'].each... , created new fields sub-fields of results.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -