Read Oracle Database Table Data vi Logstash to insert into ElasticSearch

Dear all,

I am trying to connect with table from Oracle Database, and read records through logstash, and then to insert into Elastic search. And the same I want to do in a Linux system.

So far I understood that I have to configure logstash input plugin.

Could you please help me, how can I configure the same.

Thanks in advance.

You can use JDBC input plugin for getting the data from oracle database.
For that we have to provide path to JDBC driver, Connection string, User, Password, Schedule(Logstash will poll the DB based on the Cron), Statement(Query) etc., in the configuration.
it looks something like this:

input {
  jdbc {
    jdbc_driver_library => "mysql-connector-java-5.1.36-bin.jar"
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/mydb"
    jdbc_user => "user"
    jdbc_password => "password"
    schedule => "* * * * *"
    statement => "SELECT * from songs where artist = :favorite_artist"
  }
}

refer the below for more inputs

Thank you @sai_saran1 !!

Its working fine :slight_smile:

I created logstash-ora.conf file in /etc/logstash/conf.d/ directory.
And placed required oracle connection string with credentials, and tried with a simple query , "select * from DUAL". And its working perfectly fine.. :slight_smile:
You can see in the below screenshot, "rawsearchdata" index got created!!

		 input {
 			jdbc {
   				    jdbc_validate_connection => true
  			     	    jdbc_connection_string => "jdbc:oracle:thin:@192.168.1.2:1881/xe"
      				    jdbc_user => "user_details"
      				    jdbc_password => "user_password"
      				    jdbc_driver_library => "/usr/share/logstash/bin/ojdbc7.jar"
      				    jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
                        statement => "select * from DUAL"
  			       }
        }
 
output {
 elasticsearch {
   					hosts => ["http://localhost:9200"]
   					index => "rawsearchdata"
   					#user => "elastic"
  					#password => "changeme"
                }
         }
		 

1 Like

Dear all,

Can I call a stored procedure in logstash config output? Please help me with syntax.

Thanks in advance.

Saroj

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.