curl -XPUT elastic:changeme@192.168.232.141:9200/_template/nginx -d '
{
"template" : "nginx*",
"order": 0,
"index_patterns": [
"nginx*"
],
"settings" : {
"refresh_interval": "30s",
"merge.policy.max_merged_segment": "1000mb",
"translog.durability": "async",
"translog.flush_threshold_size": "2gb",
"translog.sync_interval": "100s",
"index" : {
"number_of_shards" : "11",
"number_of_replicas" : "0"
}
},
"mappings" : {
"_default_" : {
"_all" : {
"enabled" : true,
"norms" : false
},
"dynamic_templates" : [
{
"message_field" : {
"path_match" : "message",
"match_mapping_type" : "string",
"mapping" : {
"type" : "text",
"norms" : false
}
}
},
{
"string_fields" : {
"match" : "*",
"match_mapping_type" : "string",
"mapping" : {
"type" : "text",
"norms" : false,
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 1024
}
}
}
}
}
],
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"type": "keyword"
},
"url_args": {
"type": "nested",
"properties": {
"key": {
"type": "keyword"
},
"value": {
"type": "keyword"
}
}
}
}
}
}
}
在es服务器上执行上面,根据需求修改模板信息
查询模板可以看到test已经生成
curl -XGET http://elastic:changeme@192.168.232.141:9200/_cat/templates
template_1 zhouls* 0
test logstash-* 0 50001
logstash logstash-* 0 50001
.ml-anomalies- .ml-anomalies-* 0 5060899
.ml-notifications .ml-notifications 0 5060899
.monitoring-alerts .monitoring-alerts-6 0 5050099
.ml-meta .ml-meta 0 5060899
template_2 test* 0
triggered_watches .triggered_watches* 2147483647
.ml-state .ml-state 0 5060899
security_audit_log .security_audit_log* 2147483647
.monitoring-logstash .monitoring-logstash-6-* 0 5050099
security-index-template .security 1000
watches .watches* 2147483647
.monitoring-kibana .monitoring-kibana-6-* 0 5050099
.monitoring-es .monitoring-es-6-* 0 5050099
.watch-history-6 .watcher-history-6* 2147483647
查看test模板信息
curl -XGET http://elastic:changeme@192.168.232.141:9200/_template/test
说明: (1)模板template_2匹配所有的以test开头的索引。
(2)索引模板是template_2,索引是test*。
删除模板
curl -XDELETE http://elastic:changeme@192.168.232.141:9200/_template/template_1
ES添加新的模板
最新推荐文章于 2025-02-19 20:52:19 发布