1、查看模板
curl -XGET ‘http://192.168.60.13:9200/_template?pretty’
curl -XGET 'http://10.225.6.10:9200/_template?pretty'
**返回值**
".monitoring-alerts" : {
"order" : 0,
"version" : 6070299,
"index_patterns" : [
".monitoring-alerts-6"
],
"settings" : {
"index" : {
"format" : "6",
"codec" : "best_compression",
"number_of_shards" : "1",
"auto_expand_replicas" : "0-1",
"number_of_replicas" : "0"
}
},
"mappings" : {
"doc" : {
"dynamic" : false,
"properties" : {
"timestamp" : {
"type" : "date"
},
"update_timestamp" : {
"type" : "date"
},
"resolved_timestamp" : {
"type" : "date"
},
"prefix" : {
"type" : "text"
},
"message" : {
"type" : "text"
},
"suffix" : {
"type" : "text"
},
"metadata" : {
"properties" : {
"cluster_uuid" : {
"type" : "keyword"
},
"link" : {
"type" : "keyword"
},
"severity" : {
"type" : "short"
},
"type" : {
"type" : "keyword"
},
"version" : {
"type" : "keyword"
},
"watch" : {
"type" : "keyword"
}
}
}
}
}
},
"aliases" : { }
}
}
2、导入模板
通过postman最好操作 如下图
返回值
查看模板
可以看到已经生效
第二种方式:
当前目录放入 test.json 内容为模板 如上图所示
curl -H 'Content-Type: application/json' -XPUT 'http://10.225.6.10:9200/_template/automatic_safety_score' -d @test.json
teset.jso内容如下:
{
"order":0,
"index_patterns":[
"automatic_safety_score"
],
"settings":{
},
"mappings":{
"_doc":{
"_source":{
},
"dynamic_templates":[
{
"string_fields":{
"mapping":{
"ignore_above":256,
"type":"keyword"
},
"match_mapping_type":"string"
}
}
],
"_all":{
"enabled":false
},
"properties":{
"customize_score_time":{
"format":"strict_date_optional_time||epoch_millis",
"type":"date",
"doc_values":true
}
}
}
},
"aliases":{
}
}
返回值为:
至此则成功添加模板!
删除模板
curl -XDELETE 'http://192.168.60.13:9200/_template/filebeat