Failed to Import JSON data to elastic via logstash


(Guta Saputra) #1

hi, i tried to import json data to my elastic via logstash.
this is my config :

config_online.conf

input
{
file
{
path => ["/usr/local/Cellar/logstash/5.1.1/config_oneline.json"]
start_position => "beginning"
}
}

filter
{
mutate
{
replace => [ "message", "%{message}" ]
gsub => [ 'message','\n','']
}
if [message] =~ /^{.*}$/
{
json { source => message }
}

}

output
{
elasticsearch {
protocol => "http"
codec => json
host => "localhost"
index => "json"
embedded => true
}
stdout { codec => rubydebug }
}

but when i try to running this with :

logstash -f config_oneline.conf

i got this error msg :

[2017-01-20T14:21:54,282][ERROR][logstash.agent ] fetched an invalid config {:config=>"input \n{\n file \n {\n path => ["/usr/local/Cellar/logstash/5.1.1/config_oneline.json"]\n start_position => "beginning"\n }\n}\n\nfilter \n{\n mutate\n {\n replace => [ "message", "%{message}" ]\n gsub => [ 'message','\n','']\n }\n if [message] =~ /^{.*}$/\n {\n json { source => message }\n }\n\n}\n\noutput\n{ \n elasticsearch {\n protocol => "http"\n codec => json\n host => "localhost"\n index => "json"\n embedded => true\n }\n\n stdout { codec => rubydebug }\n}\n\n", :reason=>"Something is wrong with your configuration."}

how can i solve this issue?
pls help me

thank you


(Magnus B├Ąck) #2

You're using a number of old options in your elasticsearch output. Please consult the documentation for your version of Logstash to see what options are available.


(system) #3

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