Input {jdbc {jdbc_connection_string="Jdbc:mysql://localhost:3306/crm?zerodatetimebehavior=converttonull"Jdbc_user="Root"Jdbc_password=""jdbc_driver_library="D:/siyang/elasticsearch-5.2.2/logstash-5.2.2/mysql-connector-java-5.1.30.jar"Jdbc_driver_class="Com.mysql.jdbc.Driver"jdbc_paging_enabled="true"jdbc_page_size="50000"Statement_filepath="Filename.sql"Schedule="* * * * *"type="Jdbc_office"} JDBC {jdbc_connection_string="Jdbc:mysql://localhost:3306/crm?zerodatetimebehavior=converttonull"Jdbc_user="Root"Jdbc_password=""jdbc_driver_library="D:/siyang/elasticsearch-5.2.2/logstash-5.2.2/mysql-connector-java-5.1.30.jar"Jdbc_driver_class="Com.mysql.jdbc.Driver"jdbc_paging_enabled="true"jdbc_page_size="50000"Statement="SELECT * from Sys_user"Schedule="* * * * *"type="Jdbc_user"}}output {stdout {codec=Json_lines}if[Type] = ="Jdbc_office"{elasticsearch {hosts="localhost:9200"Index="CONTACTS4"Document_type="Office1"document_id="%{id}" } } if[Type] = ="Jdbc_user"{elasticsearch {hosts="localhost:9200"Index="CONTACTS4"Document_type="User1"document_id="%{id}" } }}
Note that the fields in the database do not use the type, if any, as into other names, otherwise, there will be an exception to judge
LOGSTASH-INPUT-JDBC simultaneous synchronization of multiple tables