theangryangel / logstash-output-jdbc

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

Can the plugin be used to UPDATE a table #125

Closed avitaleli closed 6 years ago

avitaleli commented 6 years ago

Hi,

I have an event: {"type":"users","user_id":"abcd1234","@version":"1","@timestamp":"2018-05-09T14:02:01.183Z"}

I am trying to do the following:

output {
  jdbc {
    driver_jar_path => "/path/to/mssql-jdbc.jar"
    driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
    connection_string => "${MSSQL_URL}"
    username => "${MSSQL_USER}"
    password => "${MSSQL_PASS}"
    statement => [ "UPDATE orders SET modified_date = CURRENT_TIMESTAMP WHERE user_id = ?", "user_id" ]
  }
}

But for some reason it does not work, I also don't get any logs cause there is some problem with SLF4J:

[[33mlogstash |^[[0m [2018-05-09T13:21:18,998][INFO ][logstash.outputs.jdbc ] JDBC - Starting up ^[[33mlogstash |^[[0m SLF4J: Class path contains multiple SLF4J bindings. ^[[33mlogstash |^[[0m SLF4J: Found binding in [jar:file:/usr/share/logstash/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] ^[[33mlogstash |^[[0m SLF4J: Found binding in [jar:file:/usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-output-jdbc-5.3.0-java/vendor/jar-dependencies/runtime-jars/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class] ^[[33mlogstash |^[[0m SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. ^[[33mlogstash |^[[0m SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory] ^[[33mlogstash |^[[0m [2018-05-09T13:21:19,083][INFO ][com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Starting... ^[[33mlogstash |^[[0m [2018-05-09T13:21:19,307][INFO ][com.zaxxer.hikari.pool.PoolBase] HikariPool-1 - Driver does not support get/set network timeout for connections. (This operation is not supported.) ^[[33mlogstash |^[[0m [2018-05-09T13:21:19,411][INFO ][com.zaxxer.hikari.HikariDataSource] HikariPool-1 - Start completed.

  1. Can I use this output plugin to update a table?
  2. Any idea how to solve this conflict of SLF4J, I assume that other plugins have the same problem

Thank you

avitaleli commented 6 years ago

I found the problem, the problem was caused due to wrong querying in the input phase