我的配置
input {
http {
host => "0.0.0.0"
port => "18080"
codec => es_bulk {
}
type => "http"
}
heartbeat {
interval => 10
type => "heartbeat"
}
}
output {
if [type] == "heartbeat" {
elasticsearch {
hosts => "1.2.3.4:9200"
index => "logstash-%{+YYYY.MM.dd}" <-- error
index => "logstash" <-- not error
}
} else {
elasticsearch {
hosts => "1.2.3.4:9200"
index => "%{[@metadata][_index]}"
document_type => "%{[@metadata][_type]}"
template_name => "%{[@metadata][_template]}"
}
}
stdout {
codec => rubydebug {
metadata => true
}
}
}
与此同时,我希望收到&#34;输入-http&#34;和#34;心跳&#34;。 以时间形式插入索引名称时发生错误。
出了什么问题?
错误日志
[2017-09-06T18:49:14,759][ERROR][logstash.outputs.elasticsearch] Failed to install template. {:message=>"Malformed escape pair at index 11: /_template/%{[@metadata][_template]}", :class=>"Java::JavaNet::URISyntaxException", :backtrace=>["java.net.URI$Parser.fail(java/net/URI.java:2848)", "java.net.URI$Parser.scanEscape(java/net/URI.java:2978)", "java.net.URI$Parser.scan(java/net/URI.java:3001)", "java.net.URI$Parser.checkChars(java/net/URI.java:3019)", "java.net.URI$Parser.parseHierarchical(java/net/URI.java:3105)", "java.net.URI$Parser.parse(java/net/URI.java:3063)", "java.net.URI.<init>(java/net/URI.java:588)", "java.lang.reflect.Constructor.newInstance(java/lang/reflect/Constructor.java:423)", "RUBY.format_url(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb:96)", "RUBY.perform_request(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/manticore_adapter.rb:67)", "RUBY.perform_request_to_url(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:269)", "RUBY.perform_request(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:257)", "RUBY.with_connection(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:347)", "RUBY.perform_request(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:256)", "RUBY.head(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client/pool.rb:264)", "RUBY.template_exists?(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client.rb:318)", "RUBY.template_install(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/http_client.rb:78)", "RUBY.install(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/template_manager.rb:29)", "RUBY.install_template(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/template_manager.rb:9)", "RUBY.install_template(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:62)", "RUBY.register(/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:29)", "RUBY.register(/home1/user/apps/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:9)", "RUBY.register(/home1/user/apps/logstash/logstash-core/lib/logstash/output_delegator.rb:41)", "RUBY.register_plugin(/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:268)", "RUBY.register_plugins(/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:279)", "org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)", "RUBY.register_plugins(/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:279)", "RUBY.start_workers(/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:288)", "RUBY.run(/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:214)", "RUBY.start_pipeline(/home1/user/apps/logstash/logstash-core/lib/logstash/agent.rb:398)", "java.lang.Thread.run(java/lang/Thread.java:745)"]}
[2017-09-06T18:49:14,837][FATAL][logstash.runner ] An unexpected error occurred! {:error=>#<LogStash::Error: timestamp field is missing>, :backtrace=>["org/logstash/ext/JrubyEventExtLibrary.java:202:in `sprintf'", "/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:173:in `event_action_params'", "/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:48:in `event_action_tuple'", "/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:42:in `multi_receive'", "org/jruby/RubyArray.java:2414:in `map'", "/home1/user/apps/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.3.5-java/lib/logstash/outputs/elasticsearch/common.rb:42:in `multi_receive'", "/home1/user/apps/logstash/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:13:in `multi_receive'", "/home1/user/apps/logstash/logstash-core/lib/logstash/output_delegator.rb:47:in `multi_receive'", "/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:407:in `output_batch'", "org/jruby/RubyHash.java:1342:in `each'", "/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:406:in `output_batch'", "/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:352:in `worker_loop'", "/home1/user/apps/logstash/logstash-core/lib/logstash/pipeline.rb:317:in `start_workers'"]}