Timo Ademeit
Timo Ademeit

Reputation: 715

Import MySQL-Entrys in Elasticsearch over Logstash

I wanted to know how I can easily import data from my MySQL Database to my Elasticsearch Server using Logstash.

I have a Spring Boot App and want to import the information there.

Upvotes: 0

Views: 247

Answers (1)

Kulasangar
Kulasangar

Reputation: 9464

In order for you to import data from a MySQL data to your elasticsearch index, you should be using the jdbc plugin as @hurb suggested above.

Your logstash jdbc input could look like this:

input {
    jdbc {
        jdbc_connection_string => "jdbc:mysql://yourhost:3306/yourdb" 
        jdbc_user => "root"
        jdbc_password => "root"
        jdbc_validate_connection => true
        jdbc_driver_library => "/pathtojar/mysql-connector-java-5.1.39-bin.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        schedule => "* * * * *" <-- if you need the query to be running continuously at a time span 
        statement => "SELECT * FROM yourtable" <-- change the query to your need        
        jdbc_paging_enabled => "true"
        jdbc_page_size => "50000"
    }
}

The above is just a sample, so that you could reproduce. Hope it helps!

Upvotes: 1

Related Questions