Hi All,
String JSON messages cannot parsed successfully by logstash, following is my logstash configuration (similar to http://stackoverflow.com/questions/30542879/how-to-use-logstashs-json-filter)
input {
kafka {
topic_id => "neptunus"
zk_connect => "zookeeper4kafka:2181"
type => "json"
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
host => "140.92.25.59"
codec => "json"
protocol => "http"
index => "logstash-%{+YYYY.MM.dd}"
}
mongodb {
uri => "mongodb://mongo4kafka"
database => kafkatest
collection => hellomongo
codec => "json"
}
mongodb {
uri => "mongodb://mongo264kafka"
database => kafkatest
collection => hellomongo
codec => "json"
}
}
When the JSON value of keys doesn't include String, it always works fine, but if there is a String value of any key of JSON message, it will occur some error like following:
{
"message" => "{\"address\":\"55555\",\"b\":553,\"timestamp\":1425094186000}",
"@version" => "1",
"@timestamp" => "2015-10-21T05:48:19.660Z",
"host" => "logstashpubkafka",
"path" => "/var/log/kafka/test",
"type" => "json",
"address" => "55555",
"b" => 553,
"timestamp" => 1425094186000
}
{
"message" => "{\"address\":\"abcde\",\"b\":553,\"timestamp\":1425094186000}",
"@version" => "1",
"@timestamp" => "2015-10-21T05:48:35.672Z",
"host" => "logstashpubkafka",
"path" => "/var/log/kafka/test",
"type" => "json",
"address" => "abcde",
"b" => 553,
"timestamp" => 1425094186000
}
failed action with response of 400, dropping action: ["index", {:_id=>nil, :_index=>"logstash-2015.10.21", :_type=>"json", :_routing=>nil}, #<LogStash::Event:0x4820eb7d @metadata_accessors=#<LogStash::Util::Accessors:0x6859c7bb @store={"retry_count"=>0}, @lut={}>, @cancelled=false, @data={"message"=>"{\"address\":\"abcde\",\"b\":553,\"timestamp\":1425094186000}", "@version"=>"1", "@timestamp"=>"2015-10-21T05:48:35.672Z", "host"=>"logstashpubkafka", "path"=>"/var/log/kafka/test", "type"=>"json", "address"=>"abcde", "b"=>553, "timestamp"=>1425094186000}, @metadata={"retry_count"=>0}, @accessors=#<LogStash::Util::Accessors:0x2997ee7e @store={"message"=>"{\"address\":\"abcde\",\"b\":553,\"timestamp\":1425094186000}", "@version"=>"1", "@timestamp"=>"2015-10-21T05:48:35.672Z", "host"=>"logstashpubkafka", "path"=>"/var/log/kafka/test", "type"=>"json", "address"=>"abcde", "b"=>553, "timestamp"=>1425094186000}, @lut={"type"=>[{"message"=>"{\"address\":\"abcde\",\"b\":553,\"timestamp\":1425094186000}", "@version"=>"1", "@timestamp"=>"2015-10-21T05:48:35.672Z", "host"=>"logstashpubkafka", "path"=>"/var/log/kafka/test", "type"=>"json", "address"=>"abcde", "b"=>553, "timestamp"=>1425094186000}, "type"]}>>] {:level=>:warn}
Anyone can help