我正在使用Logstash练习,我无法理解此错误的来源。 我想通过删除一个字段并重命名一个来修改索引。 我正在使用Logstash 5.6.2
这是我的参赛作品的一个例子:
{
"_index": "test-shakespeare-italian",
"_type": "logs",
"_id": "AV8QsD5pzoUbREG_8icr",
"_score": 1,
"_source": {
"nome_opera": "Henry IV",
"battuta_numero": "3.2.9",
"battuta": "Make me believe that thou art only markd",
"@timestamp": "2017-10-12T13:05:06.519Z",
"id_battuta": 1841,
"dialogo_numero": 1,
"@version": "1",
"interlocutore": "KING HENRY IV"
}
}
这是我的管道:
# this pipeline updates an existing index by
# changing name of field "nome_opera" in "opera"
# dropping field "dialogo numero"
input {
elasticsearch {
hosts => "localhost"
index => "test-shakespeare-italian"
query => '{"query": {"match_all": {}}}'
}
}
filter {
mutate {
rename => { "nome_opera" => "opera"}
remove_field => "dialogo_numero"
}
}
output {
elasticsearch {
index => "test-shakespeare-italian"
action => "update"
document_id => "OOW-j2DeSCmnsVWVsywOVQ"
hosts => "localhost:9200"
version => "1"
}
#stdout { codec => rubydebug }
}
首先我没有使用版本字段,但这会产生以下错误:
[2017-10-13T11:29:25,464][WARN ][logstash.outputs.elasticsearch] Failed action. {:status=>409, :action=>["update", {:_id=>"OOW-j2DeSCmnsVWVsywOVQ", :_index=>"test-shakespeare-italian", :_type=>"logs", :_routing=>nil, :_retry_on_conflict=>1}, 2017-10-12T13:05:08.907Z %{host} %{message}], :response=>{"update"=>{"_index"=>"test-shakespeare-italian", "_type"=>"logs", "_id"=>"OOW-j2DeSCmnsVWVsywOVQ", "status"=>409, "error"=>{"type"=>"version_conflict_engine_exception", "reason"=>"[logs][OOW-j2DeSCmnsVWVsywOVQ]: version conflict, current version [17901] is different than the one provided [17900]", "index_uuid"=>"OOW-j2DeSCmnsVWVsywOVQ", "shard"=>"3", "index"=>"test-shakespeare-italian"}}}}
然后我添加了版本字段,但管道仍然失败并出现以下错误:
[2017-10-13T11:38:39,467][ERROR][logstash.outputs.elasticsearch] Encountered an unexpected error submitting a bulk request! Will retry. {:error_message=>"undefined method `sanitized' for \"http://localhost:9200/_bulk\":String", :class=>"NoMethodError", :backtrace=>["/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:249:in `safe_bulk'", "/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:119:in `submit'", "/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:87:in `retrying_submit'", "/usr/local/Cellar/logstash/5.6.2/libexec/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-7.4.0-java/lib/logstash/outputs/elasticsearch/common.rb:38:in `multi_receive'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/output_delegator_strategies/shared.rb:13:in `multi_receive'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/output_delegator.rb:49:in `multi_receive'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:436:in `output_batch'", "org/jruby/RubyHash.java:1342:in `each'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:435:in `output_batch'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:381:in `worker_loop'", "/usr/local/Cellar/logstash/5.6.2/libexec/logstash-core/lib/logstash/pipeline.rb:342:in `start_workers'"]}
这个 https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/612
这让我觉得这是一个错误,而不是我的错。 遗憾的是,这些链接中没有提供真正的解决方案,我是否必须恢复到旧版本的logstash?还有其他想法吗?
答案 0 :(得分:0)
如果您通过stdout获取最终结果并通过批量api应用它,它是否有效?
我认为过滤处理器
之后你的最终JSON一定是个问题