在logstash conf中为elasticsearch设置'host'未知

时间:2017-08-03 11:16:56

标签: logstash

我的logstash.conf文件和mysql-connector-java-5.1.38.jar都位于F:\ Software \ logstash-5.5.1 \ logstash-5.5.1 \ bin位置 在cmd中运行conf文件时出现以下错误:

  

F:\ Software \ logstash-5.5.1 \ logstash-5.5.1 \ bin> logstash -f logstash.conf   错误StatusLogger找不到log4j2配置文件。使用默认配置:仅将错误记录到控制台。   将Logstash的日志发送到F:/Software/logstash-5.5.1/logstash-5.5.1/logs,现在通过log4j2.properties配置   [2017-08-03T16:01:17,142] [错误] [logstash.outputs.elasticsearch]未知设置'host'为elasticsearch   [2017-08-03T16:01:17,149] [错误] [logstash.agent]无法创建管道{:reason =>“您的配置出现问题。”}

以下是我的conf文件:

input {
jdbc {
    # MySql jdbc connection string to our database, testdb
    jdbc_connection_string => "jdbc:mysql://localhost:3306/testdb"
    # The user we wish to execute our statement as
    jdbc_user => "root"
    jdbc_password => "root"
    # The path to our downloaded jdbc driver
    jdbc_driver_library => "F:/Software/logstash-5.5.1/logstash-5.5.1/bin/mysql-connector-java-5.1.38/mysql-connector-java-5.1.38.jar"
    # The name of the driver class for Postgresql
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    # our query
    statement => "SELECT * from testtable"
}

}

output {
stdout { codec => json_lines }
elasticsearch{
 hosts => ["localhost:9200"]
 protocol => "http" 
 index => "test-migrate"
 document_type => "data"
}

}

1 个答案:

答案 0 :(得分:0)

这是标准和基本的conf文件

祝你好运!!!!

input {
    jdbc {
        jdbc_driver_library => "/mysql-connector-java-5.1.44-bin.jar"
        jdbc_driver_class => "com.mysql.jdbc.Driver"
        jdbc_connection_string => "jdbc:mysql://localhost:3306/yourdatabase"
        jdbc_user => "root"
        jdbc_password => ""
        statement => "SELECT * from yourtable"
    }
}
output {
    #stdout {codec => rubydebug}
    elasticsearch {
        hosts => "localhost:9200"
        index => "inandi"
        document_type => "name"
        document_id => "%{name}"
    }
}