theangryangel / logstash-output-jdbc

JDBC output for Logstash
MIT License
256 stars 101 forks source link

Plugin does not support exporting embedded properties #115

Closed ehtishamkhan closed 6 years ago

ehtishamkhan commented 6 years ago

input { elasticsearch { hosts => ["localhost:9200"] index => "documents" query => '{ "query": { "query_string": { "query": "*" } } }' } } output { jdbc { driver_jar_path => "" connection_string => "" statement => [ "INSERT INTO DOCUMENTS (resourceName, content) VALUES(?, ?)", "file.filename", "content" ] } }

resourceName is not populated in the target table which is an embedded property - file.filename

theangryangel commented 6 years ago

Try the sprintf syntax instead for that field. I.e %{file.filename}

ehtishamkhan commented 6 years ago

That didn't help. It inserted %{file.filename} as a string in the column.

input { elasticsearch { hosts => ["localhost:9200"] index => "documents" query => '{ "query": { "query_string": { "query": "*" } } }' } } output { jdbc { driver_jar_path => "" connection_string => "" statement => [ "INSERT INTO DOCUMENTCONTENT (resourceName, content) VALUES(?, ?)", "%{file.filename}", "content" ] } }

theangryangel commented 6 years ago

I’m that case try %{file[filename]} or %{file['filename']}. I’m pretty sure logstash’s sprintf function supports this but I can’t remember what syntax it uses off the top of my head.

ehtishamkhan commented 6 years ago

Awesome! %{file[filename]} works.

%{file['filename']} inserts %{file['filename']} as a string in the target column.