Hi,
I've tried to index some docs with logstash using jdbc. But it always fail because it is not able to index date with format yyyyMMdd
input {
jdbc {
jdbc_connection_string => "jdbc:sqlserver://localhost;databaseName=BD;integratedSecurity=false;"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_driver_library => "/root/sqljdbc42.jar"
statement => "SELECT *
FROM table"
}
}
filter {
mutate {
copy => { "movimientoid" => "[@metadata][_id]"}
remove_field => ["@timestamp", "movimientoid"]
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "table"
document_id => "%{[@metadata][_id]}"
}
#stdout{ }
}
But I always received the same error:
[WARN ] 2020-04-27 18:32:49.989 [[main]>worker0] elasticsearch - Could not index event to Elasticsearch. {:status=>400, :action=>["index", {:_id=>"25725798", :_index=>"movimientos", :_type=>"_doc", :routing=>nil}, #LogStash::Event:0x4cc06d9e], :response=>{"index"=>{"_index"=>"movimientos", "_type"=>"_doc", "_id"=>"25725798", "status"=>400, "error"=>{"type"=>"mapper_parsing_exception", "reason"=>"failed to parse field [fecha] of type [date] in document with id '25725798'", "caused_by"=>{"type"=>"illegal_argument_exception", "reason"=>"failed to parse date field [2009-04-21T22:00:00.000Z] with format [basic_date]", "caused_by"=>{"type"=>"date_time_parse_exception", "reason"=>"date_time_parse_exception: Text '2009-04-21T22:00:00.000Z' could not be parsed at index 4"}}}}}}
I don't know how can i resolve this. Could someone help me??
Furthermore, the SQL query returns the field fecha with yyyy-MM-dd format.
Thanks.