logstash写数据到elasticsearch如何指定多个数据 template
2018-01-04 17:41
435 查看
之前在配置从logstash写数据到elasticsearch时,指定单个数据模板没有问题,但是在配置多个数据模板时候,总是不成功,后来找了很多资料,终于找到解决办法,就是要多加一个配置项: template_name ,切该名字必须全部为小写。
参考配置信息:
模板的配置请参见:http://qindongliang.iteye.com/blog/2290384
没指定之前的写法:
修改后的文件格式:
temp.json参考格式:
{
"template": "index_ytx_inlife_item_category",
"version": 50001,
"settings": {
"index.refresh_interval": "5s"
},
"mappings": {
"_default_": {
"_all": {
"enabled": true,
"norms": false
},
"dynamic_templates": [
{
"template_1" : {
"match" : "name",
"mapping" : {
"type" : "string",
"analyzer":"ik_smart",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
},
{
"template_2" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
]
}
}
}
参考配置信息:
output { if [type] == "log_01" { elasticsearch { cluster => 'elasticsearch' host => 'x.x.x.x' index => 'log_01-%{+YYYY-MM-dd}' port => '9300' workers => 1 template => "/data/logstash/conf/template_01.json" template_name => "template_01.json" template_overwrite => true } } if [type] == "log_02" { elasticsearch { cluster => 'elasticsearch' host => 'x.x.x.x' index => 'log_02-%{+YYYY-MM-dd}' port => '9300' workers => 1 template => "/data/logstash/conf/template_02.json" template_name => "template_01.json" template_overwrite => true } } }
模板的配置请参见:http://qindongliang.iteye.com/blog/2290384
没指定之前的写法:
修改后的文件格式:
temp.json参考格式:
{
"template": "index_ytx_inlife_item_category",
"version": 50001,
"settings": {
"index.refresh_interval": "5s"
},
"mappings": {
"_default_": {
"_all": {
"enabled": true,
"norms": false
},
"dynamic_templates": [
{
"template_1" : {
"match" : "name",
"mapping" : {
"type" : "string",
"analyzer":"ik_smart",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
},
{
"template_2" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string",
"index" : "not_analyzed"
}
}
}
]
}
}
}
相关文章推荐
- logstash 向elasticsearch写入数据,如何指定多个数据template
- logstash向elasticsearch写入数据,如何指定多个数据template
- logstash 向elasticsearch写入数据,怎样指定多个数据template
- Logstash中如何处理到ElasticSearch的数据映射
- 如何在elasticsearch中查看Logstash打到elasticsearch的数据
- logstash的output配置中指定elasticsearch的template
- logstash使用template提前设置好maping同步mysql数据到Elasticsearch5.5.2
- logstash 如何处理 mongodb 导出来的 _id value数据。 how to custom fields of logstash by mongo mapreduce exported data.(example format: {_id:"xxx"} , value:{})
- Mysql如何指定新插入的数据的起始自增主键id
- matlab中如何保存数据到指定文件夹中?
- Sql Server 如何获取指定一行数据?在没有自动增长列的情况下
- 如何讲数据库里的数据写入到指定的XML中
- YUV420如何扣取指定区域的图像数据
- logstash采集规范与elasticsearch的template 、mapping 详细介绍
- 第三节 ElasticSearch数据导入之Logstash
- 如何备份ElasticSearch索引数据到HDFS上
- YUV420如何扣取指定区域的图像数据
- 如何生成指定均值和协方差矩阵的二维高斯分布数据
- ElasticSearch如何添加,检索数据
- 如何从Subversion的dump备份中获取指定目录的数据操作步骤