elasticsearch 模板管理

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最好操作 如下图

![在这里插入图片描述](https://img-blog.csdnimg.cn/01ac09e988b74fc892e715e6a8b85ac3.png
返回值
在这里插入图片描述
查看模板
在这里插入图片描述

可以看到已经生效

第二种方式:

当前目录放入 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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值