Logstash无法连接到弹性搜索

时间:2017-07-19 10:40:19

标签: elasticsearch logstash kibana

{:timestamp=>"2017-07-19T15:56:36.517000+0530", :message=>"Attempted to send a bulk request to Elasticsearch configured at '[\"http://localhost:9200\"]', but Elasticsearch appears to be unreachable or down!", :error_message=>"Connection refused (Connection refused)", :class=>"Manticore::SocketException", :level=>:error}
{:timestamp=>"2017-07-19T15:56:37.761000+0530", :message=>"Connection refused (Connection refused)", :class=>"Manticore::SocketException", :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.0-java/lib/manticore/response.rb:37:in `initialize'", "org/jruby/RubyProc.java:281:in `call'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.0-java/lib/manticore/response.rb:79:in `call'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.0-java/lib/manticore/response.rb:256:in `call_once'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/manticore-0.6.0-java/lib/manticore/response.rb:153:in `code'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/http/manticore.rb:84:in `perform_request'", "org/jruby/RubyProc.java:281:in `call'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/base.rb:257:in `perform_request'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/http/manticore.rb:67:in `perform_request'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/sniffer.rb:32:in `hosts'", "org/jruby/ext/timeout/Timeout.java:147:in `timeout'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/sniffer.rb:31:in `hosts'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/base.rb:79:in `reload_connections!'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:72:in `sniff!'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:60:in `start_sniffing!'", "org/jruby/ext/thread/Mutex.java:149:in `synchronize'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:60:in `start_sniffing!'", "org/jruby/RubyKernel.java:1479:in `loop'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:59:in `start_sniffing!'"], :level=>:error}
{:timestamp=>"2017-07-19T15:56:38.520000+0530", :message=>"Attempted to send a bulk request to Elasticsearch configured at '[\"http://localhost:9200\"]', but Elasticsearch appears to be unreachable or down!", :error_message=>"Connection refused (Connection refused)", :class=>"Manticore::SocketException", :level=>:error}

虽然在端口127.0.0.1:9200上运行Elastic搜索 我不明白logstash采用这种配置的位置 我还没有配置logstash来连接localhost上的弹性搜索

在logstash.service

ExecStart=/usr/share/logstash/bin/logstash "--path.settings" "/etc/logstash"

并且在 在/ etc / logstash 我有logstash.yml

path.config: /etc/logstash/conf.d
/etc/logstash/conf.d中的

output {
  elasticsearch { hosts => ["10.2.0.10:9200"] 
  manage_template => false
  index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
  document_type => "%{[@metadata][type]}"
  }
}

2 个答案:

答案 0 :(得分:0)

conf.d是你的目录,你需要一个类似myconf.conf的文件,并采用以下格式:

input {

}

filter {
 #can be empty 
}

output {

}

应用所有更改后,您需要重新启动logstash服务,它将应用您的新更改。您还可以在LS设置logstash.yml文件中控制它,如果您需要重新启动它,一旦您对conf.d下的任何文件应用了新的更改

你也可以分解你的conf文件,如1_input.conf 2_filter.conf和99_output.conf,这样每个文件都包含自己的插件,即输入,过滤和输出。

答案 1 :(得分:0)

  • 启动Elasticsearch。
  • 为Logstash编写一个conf文件,以便将数据连接并上传到Elasticsearch。

    input {
        file {
               type => "csv"
               path => "path for csv."
               start_position => "beginning"
             }
       }
    filter {
         csv {
             columns => ["Column1","Column2"]
             separator => ","
            }
         mutate {
            convert => {"Column1" => "float"}
            }
       }
    output {
         elasticsearch {
         hosts => "http://localhost:9200"
            }
        stdout { codec => rubydebug}
    }
    
  • 可以在elasticsearch.yml文件中配置
  • elasticsearch的主机。

  • 运行conf文件(logstash.bat -f abc.conf)