0
votes

I am trying to make connection with MySQL using logstash and write into elastic search below in my code in conf file

input {
    jdbc {
        jdbc_connection_string => "jdbc:mysql://192.168.2.24:3306/test"
        # The user we wish to execute our statement as
        jdbc_user => "uname"
        jdbc_password => "pass"
        # The path to our downloaded jdbc driver
        jdbc_driver_library => "/usr/local/Cellar/logstash/6.2.4/mysql-connector-java-8.0.11.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        # our query
        statement => "SELECT * FROM report_table"
    }
}

output {
    elasticsearch {
    action => "index"
    hosts => "localhost:9200"
    index => "mysqlsample"
    document_type => "record"
    }
}

on running the above getting the below error :

Error: com.mysql.jdbc.Driver not loaded. Are you sure you've included the correct jdbc driver in :jdbc_driver_library? Exception: LogStash::ConfigurationError Stack: /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/plugin_mixins/jdbc.rb:162:in open_jdbc_connection' /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/plugin_mixins/jdbc.rb:220:in execute_statement' /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/inputs/jdbc.rb:264:in execute_query' /usr/local/Cellar/logstash/6.2.4/libexec/vendor/bundle/jruby/2.3.0/gems/logstash-input-jdbc-4.3.9/lib/logstash/inputs/jdbc.rb:250:in run' /usr/local/Cellar/logstash/6.2.4/libexec/logstash-core/lib/logstash/pipeline.rb:514:in inputworker' /usr/local/Cellar/logstash/6.2.4/libexec/logstash-core/lib/logstash/pipeline.rb:507:in block in start_input'

1
Maybe related to this: stackoverflow.com/questions/38368567/… ?Yavor

1 Answers

0
votes

Sounds like it's an issue with jdbc_driver_library => "/usr/local/Cellar/logstash/6.2.4/mysql-connector-java-8.0.11.jar".

Are you sure it's a valid path? Is that the correct connector? Maybe try to use the one that the documentation mentions: mysql-connector-java-5.1.36-bin.jar