0

I'm trying to fetch data from mongodb using Jdbc_streaming filter plugin in logstash in windows. I'm using mongo-java-driver-3.4.2.jar to connect to the database but, getting a error like this.

JavaSql::SQLException: No suitable driver found for jdbc:mongo://localhost:27017/EmployeeDB

No any luck with existing references. I'm using logstash 7.8.0 version. This is my logstash config:

jdbc_streaming {
        jdbc_driver_library => "C:/Users/iTelaSoft-User/Downloads/logstash-7.8.0/mongo-java-driver-3.4.2.jar"
        jdbc_driver_class => "com.mongodb.MongoClient"
        jdbc_connection_string => "jdbc:mongo://localhost:27017/EmployeeDB"
        statement => "select * from Employee"
        target => "name"
    }
  • 1
    Try putting the driver jar in the principal folder. (C:/Driver). I faced the same type of error then reinstalled the jdbc driver for mongo. – Max Jul 21 '20 at 17:27
  • @Max - Thanks for the reply. I tried but, no luck. I got the same error. – Rasitha Ariyarathna Jul 21 '20 at 17:40
  • 1
    Obviously it is something with the jar controller, never use logstash in windows with which I do not know if it is an official controller or one that you use, but perhaps with this link you can give your problem: https://discuss.elastic.co/t/mongodb-logstash-integration-solved/122299 – Max Jul 21 '20 at 17:48
  • I tried almost all the solutions on their forum. Nothing worked. Any way, thanks for the forum link. I will try putting the issue on it. – Rasitha Ariyarathna Jul 21 '20 at 18:04

1 Answers1

1

You can also try as follows:

  1. download https://dbschema.com/jdbc-drivers/MongoDbJdbcDriver.zip
  2. unzip and copy all the files to the path(~/logstash-7.8.0/logstash-core/lib/jars/)
  3. modify the .config file

Example:

input {
  jdbc{
    jdbc_driver_class => "com.dbschema.MongoJdbcDriver"
    jdbc_driver_library => "mongojdbc2.1.jar"
    jdbc_user => "user"
    jdbc_password => "pwd"
    jdbc_connection_string => "jdbc:mongodb://localhost:27017/EmployeeDB"
    statement => "select * from Employee"
  }
}

output {
    stdout { }
}
Max
  • 538
  • 1
  • 6
  • 16
  • Wow It worked. I spent 2 days on it. Thank you. But I had to put the full path for driver jdbc_driver_library as follows: jdbc_driver_library => "C:\Users\iTelaSoft-User\Downloads\logstash-7.8.0\logstash-core\lib\jars\mongojdbc2.1.jar" – Rasitha Ariyarathna Jul 21 '20 at 18:35