logstash-plugins / logstash-input-jdbc

Logstash Plugin for JDBC Inputs
Apache License 2.0
449 stars 187 forks source link

parameters values as command line argument #66

Open brito-rafa opened 9 years ago

brito-rafa commented 9 years ago

I would like to invoke the same logstash jdbc conf file with additional command line arguments to be translated as the "parameters" values. This way I would avoid multiple versions of the same logstash conf files with each one with a hard coded value. If there is an actual way to do so, I appreciate someone to post here :)

ppf2 commented 9 years ago

+1. The current "workaround" is not ideal (which is to pass in the entire jdbc input block as an argument via the -e parameter, and the rest of the config via -f) - which means that the jdbc user and password information will be exposed right in the command line.

./logstash -e 'input {jdbc {jdbc_driver_library => "..." jdbc_driver_class => "..." jdbc_connection_string => "..." jdbc_user => "..." jdbc_password => "..." parameters => { "input" => "test1" } statement => "select * from table1 where text = :input"}}' -f rest_of_config.conf
talevy commented 9 years ago

@rb36135 This is a great feature request! Changes in the main Logstash project would be required to enable this. If you don't mind, please open this issue against Logstash

ppf2 commented 9 years ago

@talevy Done (https://github.com/elastic/logstash/issues/4119). thx!

ppf2 commented 9 years ago

Another workaround which is nicer (or something equivalent using sed/awk, etc..):

sed s/:input/\'test3\'/ sql_template.txt > input_sql.txt |./logstash -f jdbc.conf

sql_template.txt (select * from table1 where text = :input) In the jdbc.conf, the statement file path will be pointing to input_sql.txt.