Rasitha Ariyarathna
Rasitha Ariyarathna

Reputation: 171

Connect to mongodb using logstash Jdbc_streaming filter plugin

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"
    }

Upvotes: 0

Views: 891

Answers (1)

Max
Max

Reputation: 538

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 { }
}

Upvotes: 1

Related Questions