Docs/ELK/ELK创建索引.md
2022-10-18 16:59:37 +08:00

21 lines
No EOL
917 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

如果logstash(filebeat)收集到的数据es的默认映射不能满足比如说需要把数据中的数字解析成数字类型嵌套json问题等需要定义映射mapping但是索引一般是按照日期创建的如果对每个索引创建映射非常麻烦这时可以使用索引模板。
```
PUT /_template/my_logs ## 创建一个名为 my_logs 的模板。
{
"template": "logstash-*", ## 将这个模板应用于所有以 logstash- 为起始的索引
"order": 1, ## 这个模板将会覆盖默认的 logstash 模板,因为默认模板的 order 更低
"settings": {
"number_of_shards": 1 ## 限制主分片数量为 1
},
"mappings": {
"_default_": {
"_all": {
"enabled": false ## 为所有类型禁用 _all 域
}
}
},
"aliases": {
"last_3_months": {} ## 添加这个索引至 last_3_months 别名中
}
}
```