采坑了。首先吐槽一下,下载elasticsearch的最新版本7.9.0了,配置索引模板跟原来6.X.X、6.X.X之前的都有点差别。新版的api中除了_template,又有了_index_template和_component_template,很容易混淆,让人不知所措。好了回归正题,我们这里使用的特指7.9.0的_template这个api。
事情是这样的,我在logstash配置了一个output指向elasticsearch的template:
output {
elasticsearch{
hosts => "localhost:9200"
index => "hello-world-%{+YYYY.MM.dd}"
manage_template => true
template_name => "hello-world"
template_overwrite => true
template => "D:\elk\logstash-7.9.0\config\hello-world.json"
}
}
hello-world.json内容:
{
"index_patterns": ["hello-world-%{+Y