module LogStash
This filter executes a SQL query and store the result set in the field specified as `target`. It will cache the results locally in an LRU cache with expiry
For example you can load a row based on an id from in the event
- source,ruby
-
filter {
jdbc_streaming { jdbc_driver_library => "/path/to/mysql-connector-java-5.1.34-bin.jar" jdbc_driver_class => "com.mysql.jdbc.Driver" jdbc_connection_string => ""jdbc:mysql://localhost:3306/mydatabase" jdbc_user => "me" jdbc_password => "secret" statement => "select * from WORLD.COUNTRY WHERE Code = :code" parameters => { "code" => "country_code"} target => "country_details" }
}
Prepared Statement Mode example
- source,ruby
-
filter {
jdbc_streaming { jdbc_driver_library => "/path/to/mysql-connector-java-5.1.34-bin.jar" jdbc_driver_class => "com.mysql.jdbc.Driver" jdbc_connection_string => ""jdbc:mysql://localhost:3306/mydatabase" jdbc_user => "me" jdbc_password => "secret" statement => "select * from WORLD.COUNTRY WHERE Code = ?" use_prepared_statements => true prepared_statement_name => "get_country_from_code" prepared_statement_bind_values => ["[country_code]"] target => "country_details" }
}
Tentative of abstracting JDBC logic to a mixin for potential reuse in other plugins (input/output)