【发布时间】:2014-12-17 11:10:14
【问题描述】:
我使用logstash + elasticsearch 来收集syslog,想设置ttl 进行日志老化
我在logstash中找到一个名为elasticsearch-template.json的文件,路径是logstash/logstash-1.4.2/lib/logstash/outputs/elasticsearch/elasticsearch-template.json
我像这样在文件中添加 ttl 信息:
{
"template" : "logstash-*",
"settings" : {
"index.refresh_interval" : "5s"
},
"mappings" : {
"_default_" : {
"_all" : {"enabled" : true},
"dynamic_templates" : [ {
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "string", "index" : "analyzed", "omit_norms" : true,
"fields" : {
"raw" : {"type": "string", "index" : "not_analyzed", "ignore_above" : 256}
}
}
}
} ],
"_ttl": {
"enabled": true,
"default": "1d"
},
"properties" : {
"@version": { "type": "string", "index": "not_analyzed" },
"geoip" : {
"type" : "object",
"dynamic": true,
"path": "full",
"properties" : {
"location" : { "type" : "geo_point" }
}
}
}
}
}
}
然后重启logstash,删除所有elasticsearch索引。 我在elasticsearch中检查了新索引的映射,但它并没有以这种方式工作。
如何配置索引模板?
【问题讨论】:
-
对于新访问者,有一个名为“kopf”的插件,具有很多功能。其中之一是轻松编辑模板并将其保存在编辑器中。诸如根据您的集群更改分片/副本的数量等。