简体   繁体   中英

Logstash jdbc not sending data

I'm trying to export datas from a mysql table to elastic search with logstash and the jdbc mysql driver with every process in a docker container. My problem is (with no error) their is nothing sent to elastic search.

My Dockerfile :

FROM elastic/logstash:6.3.0

ENV https_proxy=
ENV http_proxy=

COPY ./mysql-connector-java-5.1.46/mysql-connector-java-5.1.46.jar /tmp/mysql-connector-java-5.1.46.jar
COPY ./logstash.conf /tmp/logstash.conf
COPY ./logstash.yml /usr/share/logstash/config/logstash.yml

RUN logstash-plugin install logstash-input-jdbc

I run it with this command :

docker run -d --rm --name=logstach -v /data/logstash:/home/logstash logstash bin/logstash -f /tmp/logstash.conf

And here is my logstash.conf :

input {
        jdbc {
            jdbc_driver_library => "/tmp/mysql-connector-java-5.1.46.jar"
            jdbc_driver_class => "com.mysql.jdbc.Driver"
            jdbc_connection_string => "jdbc:mysql://0.0.2.22:3306/itop_db"
           jdbc_user => "admin"
            jdbc_password => "password"
            statement => "SELECT * FROM contact”
        }
    }
    output {
         elasticsearch {
            index => "contact"
            document_type => "data"
            document_id => "%{id}"
            hosts => "127.0.0.1:9200"
        }
        stdout { codec => json_lines }
    }

Every thing seems to accomplish well, except their is no new index in elastic search http://localhost:9200/_cat/indices?v

This is the output I have when i run logstash :

logstash execution output

logstash error 2

"SELECT * FROM contact” < -这可能是问题,我想你从互联网上复制这种变化? "

除了我的SQL语句中的错误外,我还需要指定容器的主机IP(在我的情况下为172.17.0.2),而不是使用127.0.0.1:9200

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM