logstash-plugins / logstash-filter-jdbc_streaming

A Logstash filter that can enrich events with data from a database
Apache License 2.0
12 stars 23 forks source link

Support for loading query from file #39

Open xvzf opened 4 years ago

xvzf commented 4 years ago

Whenever there are large and complex queries it would be nice to load them from a file instead of having a multi-line SQL-Statement in the config file. This would also eliminate the annoyance of escaped quotes when using PostgreSQL and jsonb queries

LuckyWindsck commented 4 years ago

The logstash-input-jdbc plugin has the statement_filepath setting in the source code to import SQL statement file. So I think that it's a good idea to have similar function for this plugin.

# Path of file containing statement to execute
  config :statement_filepath, :validate => :path

The statement (or statement_path) setting still holds the SQL statement but to use bind variables you must use the ? character as a placeholder in the exact order found in the prepared_statement_bind_values array. Some technologies may require connection string properties to be set, see MySQL example below.

Although the setting statement_path is mentioned in the doc, this plugin does not seem to have this function.

andsel commented 4 years ago

Since all JDBC related plugins are in the phase of merge into logstash-integration-jdbc to share the common part of the code base, probably the best is to move this issue in that repository

az-joss commented 5 months ago

Wherever it appears it must to have this feature, IMHO.