工具:
logstash5.1.1 ElasticSearch5.1.1
应用:将ElasticSearch中的实时采集到的数据同步到HDFS作为历史数据存储
1、初级版本脚本:
input{
elasticsearch {
hosts => "10.10.77.104:9200"
index => "cqct_20180508_06"
#query => "*"
}
}
output{
webhdfs{
host => "10.10.x.x"
port => 50070
path => "/usr/logstash/bm_device_es"
user => "hdfs"
codec => json_lines
}
stdout{
codec => json_lines
}
}
若脚本运行报以下错误:
[2019-03-19T23:31:04,327][ERROR][logstash.pipeline ] A plugin had an unrecoverable error. Will restart this plugin.
Plugin: <LogStash::Inputs::Elasticsearch hosts=>["10.10.77.104:9200"], index=>"cqct_20180508_06", query=>"*", id=>"87e9eae351084a8961a52ca10468572a0fdd00ee-1", enable_metric=>true, codec=><LogStash::Codecs::JSON id=>"json_6d317a05-af01-4c58-a77d-39069cf76003", enable_metric=>true, charset=>"UTF-8">, size=>1000, scroll=>"1m", docinfo=>false, docinfo_target=>"@metadata", docinfo_fields=>["_index", "_type", "_id"], ssl=>false>
Error: [400] {"error":{"root_cause":[{"type":"parse_exception","reason":"Failed

本文介绍了如何使用Logstash将Elasticsearch中的实时数据同步到HDFS,作为历史数据存储。首先,提到了一个解决脚本报错的方法,然后展示了如何过滤特定文档并根据Elasticsearch的index名称设置输出路径。接着,说明了如何按数据的start_time字段值(yyyy-MM-dd)组织HDFS存储路径。最后,讨论了当Elasticsearch中的时间戳只有13位时,如何按天同步到HDFS。
最低0.47元/天 解锁文章
312

被折叠的 条评论
为什么被折叠?



