The requested URL was not found on this server. 不管你信不信,反正我是没找到

Logstash迁移es数据,elasticsearch-input-plugin读取错误

Logstash | 作者 sonic0214 | 发布于2017年10月31日 | 阅读数:7413

logstash配置es input:


input {
    elasticsearch {
        hosts => [{iplist}]
        index => "{indexname}"
        size => 1000
        scroll => "5m"
      docinfo => true
    }
}
 


查询数据结果都是重复数据,而且在不断的写入,logstash根本停不下来。查询debug输出,发现解析结果就是一堆重复数据,所以可以定位是es input的问题。
logstash同时报如下错误:


[ERROR][logstash.pipeline        ] A plugin had an unrecoverable error. Will restart this plugin.
  Plugin: <LogStash::Inputs::Elasticsearch hosts=>["xxxx:9200"], index=>"xxxx", size=>1000, scroll=>"5m", docinfo=>true, id=>"0c0d97f3442bde5e47448f1ac819c918d0a89dc3-1", enable_metric=>true, codec=><LogStash::Codecs::JSON id=>"json_4252917a-5d59-4bee-8d9a-240f3a16c8ac", enable_metric=>true, charset=>"UTF-8">, query=>"{ \"sort\": [ \"_doc\" ] }", docinfo_target=>"@metadata", docinfo_fields=>["_index", "_type", "_id"], ssl=>false>
  Error: [400] {"error":"ElasticsearchIllegalArgumentException[Failed to decode scrollId]; nested: IOException[Bad Base64 input character decimal 123 in array position 0]; ","status":400}


已邀请:

kennywu76 - Wood

赞同来自: sonic0214

原因在于做了第一次scroll查询以后,后续根据scroll id的操作失败了。 因此反复从头开始,产生重复数据。
 
失败原因如下:
ES 1.7的scroll id直接写在request body里的:
curl -XGET 'localhost:9200/_search/scroll?scroll=1m' \ -d 'c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1'

从2.0以后,scroll ID放在了json里面:
curl -XGET 'localhost:9200/_search/scroll' -d' { "scroll" : "1m", "scroll_id" : "c2Nhbjs2OzM0NDg1ODpzRlBLc0FXNlNyNm5JWUc1" } '

从文档看2.x也兼容1.7的写法,这个阶段对应的logstash-es-input plugin在scroll操作上没有问题。
 
而看起来ES5.0以后不再向后兼容,scroll ID只能放在json body里。从而Logstash产生兼容性问题,并且在5.3.2的release notes里提到了做一个修复, 改为从json body里读取scroll id。 
https://www.elastic.co/guide/e ... ins_3
 
但这个修复没有做对于1.x版本的兼容,因此对1.x的集群做scroll会有问题。
 
规避的办法: 试一下使用logstash 5.2.x ,应该可以正常从1.7读取。

sonic0214

赞同来自:

原版本es是1.x,迁移到新版本5.x

要回复问题请先登录注册