Update a list json

Hello,

here is my field :
"servers": [ {"name":"value1", "ip":"value1"}, {"name":"value2","ip":"value2"} ]

I want to update it with elasticsearch output plugin by adding a new server.
this is my configuration:
mutate { rename => {"name" => "[server][name]" "ip" => "[server][ip]" } } ruby { code => " event['server'] = [event['server']] " }
output {
elasticsearch {
action => "update"
index => "servers"
document_type => "server"
document_id => "%{server_id}"
hosts => [""]
doc_as_upsert => true
script_lang => "groovy"
script_type => "inline"
retry_on_conflict => 3
script => '
ctx._source.servers.add("%{server}");
'
}

}

The error:

"reason"=>"failed to compile groovy script", "caused_by"=>{"type"=>"multiple_compilation_errors_exception", "reason"=>"startup failed:\n156b9df68283e0636d5ae7e1331a1c5e0b80b7ec: 2: unexpected token: name @ line 2, column 39.\n \t\t\t\t\tctx._source.servers.add("{"name"=>"localhost", "ip"=>"176.16.20.4"}"); \t\t\t\t\t\n ^\n\n1 error\n"}}}}}}, :level=>:warn}

Is there any help please.

I'm facing the same probleme. @magnusbaeck any help please ?

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