input file content:
{"_source": {"timestamp": 1612256372000, "date": "2021-02-02 16:59:32", "ip": "127.175.208.130"}}
logstash.conf:
input {
file {
path => ["/tmp/test_file"]
start_position => "beginning"
sincedb_path => "/dev/null"
codec => "json"
}
}
filter {
json {
source => "_source"
}
}
output {
stdout {
codec => json
}
}
what I want
get items in "_source", output a json string, like:
{"timestamp": 1612256372000, "date": "2021-02-02 16:59:32", "ip": "127.175.208.130"}
Error messages
[2022-08-10T09:13:01,703][WARN ][logstash.filters.json ][main][0c12318dee7f757738758c58cf376100c2248bec3723d1da4215be2e98a76069] Error parsing json {:source=>"_source", :raw=>{"timestamp"=>1612256372000, "date"=>"2021-02-02 16:59:32", "ip"=>"127.175.208.130"}, :exception=>java.lang.ClassCastException: class org.jruby.RubyHash cannot be cast to class org.jruby.RubyIO (org.jruby.RubyHash and org.jruby.RubyIO are in unnamed module of loader 'app')}
{"@timestamp":"2022-08-10T01:13:01.550111Z","@version":"1","tags":["_jsonparsefailure"],"path":"/home/hechuan/logstash/logstash-8.3.3/qwe","host":"cdh-manager","_source":{"timestamp":1612256372000,"date":"2021-02-02 16:59:32","ip":"127.175.208.130"}}