lib/logstash/inputs/jdbc.rb in logstash-input-jdbc-4.1.3 vs lib/logstash/inputs/jdbc.rb in logstash-input-jdbc-4.2.0

- old
+ new

@@ -60,11 +60,11 @@ # table that match a specific artist. The following examples demonstrates a possible # Logstash configuration for this. The `schedule` option in this example will # instruct the plugin to execute this input statement on the minute, every minute. # # [source,ruby] -# ---------------------------------- +# ------------------------------------------------------------------------------ # input { # jdbc { # jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar" # jdbc_driver_class => "com.mysql.jdbc.Driver" # jdbc_connection_string => "jdbc:mysql://localhost:3306/mydb" @@ -72,20 +72,35 @@ # parameters => { "favorite_artist" => "Beethoven" } # schedule => "* * * * *" # statement => "SELECT * from songs where artist = :favorite_artist" # } # } -# ---------------------------------- +# ------------------------------------------------------------------------------ # # ==== Configuring SQL statement # # A sql statement is required for this input. This can be passed-in via a # statement option in the form of a string, or read from a file (`statement_filepath`). File # option is typically used when the SQL statement is large or cumbersome to supply in the config. # The file option only supports one SQL statement. The plugin will only accept one of the options. # It cannot read a statement from a file as well as from the `statement` configuration parameter. # +# ==== Configuring multiple SQL statements +# +# Configuring multiple SQL statements is useful when there is a need to query and ingest data +# from different database tables or views. It is possible to define separate Logstash +# configuration files for each statement or to define multiple statements in a single configuration +# file. When using multiple statements in a single Logstash configuration file, each statement +# has to be defined as a separate jdbc input (including jdbc driver, connection string and other +# required parameters). +# +# Please note that if any of the statements use the `sql_last_value` parameter (e.g. for +# ingesting only data changed since last run), each input should define its own +# `last_run_metadata_path` parameter. Failure to do so will result in undesired behaviour, as +# all inputs will store their state to the same (default) metadata file, effectively +# overwriting each other's `sql_last_value`. +# # ==== Predefined Parameters # # Some parameters are built-in and can be used from within your queries. # Here is the list: # @@ -95,20 +110,20 @@ # `tracking_column` is set. It is updated accordingly after subsequent queries are run. # |========================================================== # # Example: # [source,ruby] -# ---------------------------------- +# --------------------------------------------------------------------------------------------------- # input { # jdbc { # statement => "SELECT id, mycolumn1, mycolumn2 FROM my_table WHERE id > :sql_last_value" # use_column_value => true -# tracking_column => id +# tracking_column => "id" # # ... other configuration bits # } # } -# ---------------------------------- +# --------------------------------------------------------------------------------------------------- # class LogStash::Inputs::Jdbc < LogStash::Inputs::Base include LogStash::PluginMixins::Jdbc config_name "jdbc" @@ -119,13 +134,13 @@ # # To use parameters, use named parameter syntax. # For example: # # [source, ruby] - # ---------------------------------- + # ----------------------------------------------- # "SELECT * FROM MYTABLE WHERE id = :target_id" - # ---------------------------------- + # ----------------------------------------------- # # here, ":target_id" is a named parameter. You can configure named parameters # with the `parameters` setting. config :statement, :validate => :string @@ -170,17 +185,18 @@ # The character encoding for specific columns. This option will override the `:charset` option # for the specified columns. # # Example: # [source,ruby] - # ---------------------------------- + # ------------------------------------------------------- # input { # jdbc { # ... # columns_charset => { "column0" => "ISO-8859-1" } # ... # } # } + # ------------------------------------------------------- # this will only convert column0 that has ISO-8859-1 as an original encoding. config :columns_charset, :validate => :hash, :default => {} public