메뉴 건너뛰기

Hello :0

elastcisearch 2.3.1로 업그레이드 후 기본 jdbc를 사용 불가 하여 logstash를 사용 시도

 

# file: contacts-index-logstash.conf
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 => "mysql"
    parameters => { "favorite_artist" => "Beethoven" }
    schedule => "* * * * *"
    statement => "SELECT * from songs where artist = :favorite_artist"
  }
}
filter {
    mutate {
      rename => {"timestamp" => "@timestamp"}
    }
}
output {
    elasticsearch {
        protocol => http
        index => "contacts"
        document_type => "contact"
        document_id => "%{uid}"
        host => "ES_NODE_HOST"
    }
}

 

실행 bin/logstash agent -f logstash.conf

 

https://www.elastic.co/blog/logstash-jdbc-input-plugin

https://www.elastic.co/guide/en/logstash/current/plugins-inputs-jdbc.html