ES添加新的模板

curl -XPUT elastic:[email protected]: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:[email protected]: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:[email protected]:9200/_template/test


說明:  (1)模板template_2匹配所有的以test開頭的索引。
    (2)索引模板是template_2,索引是test*。
  
  
    
刪除模板
curl -XDELETE http://elastic:[email protected]:9200/_template/template_1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章