Hello every one
I want to connect mongodb to elastic via logstash. I did a lot of research on this. I checked and tested many methods. Finally, I reached jdbc. I have a problem in configuring this plugin and somehow I import the file and I get an error.
The configuration is as follows:
jdbc {
jdbc_driver_library => "mongojdbc4.8.jar"
jdbc_driver_class => "Java::com.dbschema.MongoJdbcDriver"
jdbc_connection_string => "jdbc:mongodb://root:changeme@localhost:27017/databseLogstash?authSource=admin"
jdbc_user => "root"
jdbc_password => "changeme"
schedule => "* * * * * *"
statement => "db.logstashCollection.find({},{'_id': false});"
}
It displays the following error:
[2023-01-01T13:45:24,858][ERROR][logstash.javapipeline ][main][bcaa76aec0c90e69f4dea38926bfe91f49a85b51f3b4f5250b1098bc90201f07] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"root", schedule=>"* * * * * *", jdbc_password=><password>, statement=>"db.logstashCollection.find({},{'_id': false});", jdbc_driver_library=>"mongojdbc4.8.jar", jdbc_connection_string=>"jdbc:mongodb://root:123456@localhost:27017/databseLogstash?authSource=admin", id=>"bcaa76aec0c90e69f4dea38926bfe91f49a85b51f3b4f5250b1098bc90201f07", jdbc_driver_class=>"Java::com.dbschema.MongoJdbcDriver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_4e46f7fd-db79-47d3-bf5f-6b4ed82f5d8c", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_paging_mode=>"auto", jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, plugin_timezone=>"utc", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true, use_prepared_statements=>false>
Error: unable to load mongojdbc4.8.jar from :jdbc_driver_library, file not readable (please check user and group permissions for the path)
Exception: LogStash::PluginLoadingError
Stack: /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/plugin_mixins/jdbc/common.rb:59:in `block in load_driver_jars'
org/jruby/RubyArray.java:1865:in `each'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/plugin_mixins/jdbc/common.rb:54:in `load_driver_jars'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/plugin_mixins/jdbc/common.rb:34:in `load_driver'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/inputs/jdbc.rb:320:in `run'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:411:in `inputworker'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:402:in `block in start_input'
When I complete the directory plugin it shows this error:
My logstash config:
jdbc {
jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mongojdbc4.8.jar"
jdbc_driver_class => "Java::com.dbschema.MongoJdbcDriver"
jdbc_connection_string => "jdbc:mongodb://root:changeme@localhost:27017/databseLogstash?authSource=admin"
jdbc_user => "root"
jdbc_password => "changeme"
schedule => "* * * * * *"
statement => "db.logstashCollection.find({},{'_id': false});"
}
[2023-01-02T06:36:28,810][ERROR][logstash.javapipeline ][main][a936ff0509706f20c10e041797bdf10fca53317d38d4c697209fe35bb7d889ca] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"root", schedule=>"* * * * * *", jdbc_password=><password>, statement=>"db.logstashCollection.find({},{'_id': false});", jdbc_driver_library=>"/usr/share/logstash/logstash-core/lib/jars/mongojdbc4.8.jar", jdbc_connection_string=>"jdbc:mongodb://root:123456@localhost:27017/databseLogstash?authSource=admin", id=>"a936ff0509706f20c10e041797bdf10fca53317d38d4c697209fe35bb7d889ca", jdbc_driver_class=>"Java::com.dbschema.MongoJdbcDriver", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_273829a3-8cb4-4d88-97e2-d1430595c8cd", enable_metric=>true, charset=>"UTF-8">, jdbc_paging_enabled=>false, jdbc_paging_mode=>"auto", jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, plugin_timezone=>"utc", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true, use_prepared_statements=>false>
Error: #<Java::JavaLang::ClassNotFoundException: com.dbschema.MongoJdbcDriver>. Are you sure you've included the correct jdbc driver in :jdbc_driver_library?
Exception: LogStash::PluginLoadingError
Stack: /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/plugin_mixins/jdbc/common.rb:45:in `load_driver'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-jdbc-5.3.0/lib/logstash/inputs/jdbc.rb:320:in `run'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:411:in `inputworker'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:402:in `block in start_input'