38.索引生命周期管理—查询当前的模板

38.1 查询当前的模板

# 查询所有模板
GET /_template/

#查询其中某一个模板
GET /_template/logstash
{
  "logstash" : {
    "order" : 0,
    "version" : 60001,
    "index_patterns" : [
    "logstash-*"
  ],
  "settings" : {
    "index" : {
      "lifecycle" : {
        "name" : "watch-history-ilm-policy"
      },
      "number_of_shards" : "1",
      "refresh_interval" : "5s"
    }
  },
  "mappings" : {
  "dynamic_templates" : [
  {
      "message_field" : {
        "path_match" : "message",
        "mapping" : {
          "norms" : false,
          "type" : "text"
        },
        "match_mapping_type" : "string"
      }
    },
    {
      "string_fields" : {
        "mapping" : {
          "norms" : false,
          "type" : "text",
          "fields" : {
            "keyword" : {
              "ignore_above" : 256,
              "type" : "keyword"
            }
          }
        },
        "match_mapping_type" : "string",
        "match" : "*"
      }
    }
  ],
  "properties" : {
    "@timestamp" : {
      "type" : "date"
    },
    "geoip" : {
      "dynamic" : true,
      "properties" : {
        "ip" : {
          "type" : "ip"
        },
        "latitude" : {
          "type" : "half_float"
        },
        "location" : {
          "type" : "geo_point"
        },
        "longitude" : {
          "type" : "half_float"
          }
        }
      },
    "@version" : {
      "type" : "keyword"
      }
    }
  },
    "aliases" : { }
  }
}
  • 如果你不想以 logstash-* 开头创建索引,你可以先创建个模板参考如下:
PUT /_template/my_template
{
"order" : 0,
"index_patterns" : [
"filebeat_cash-*",
"filebeat_custom-*",
"filebeat_portal-*",
"filebeat_user-*",
"filebeat_hkd-*",
"filebeat_test_custom-*",
"filebeat_test_portal-*",
"filebeat_test_user-*",
"filebeat_test_hkd-*",
"filebeat_test_canal_topic-*"
],
"settings" : {
"index" : {
"number_of_shards" : "1",
"refresh_interval" : "5s"
}
},
"mappings" : {
"dynamic_templates" : [
{
"message_field" : {
"path_match" : "message",
"mapping" : {
"norms" : false,
"type" : "text"
},
"match_mapping_type" : "string"
}
},
{
"string_fields" : {
"mapping" : {
"norms" : false,
"type" : "text",
"fields" : {
"keyword" : {
"ignore_above" : 256,
"type" : "keyword"
}}
},
"match_mapping_type" : "string",
"match" : "*"
}}
],
"properties" : {
"@timestamp" : {
"type" : "date"
},
"geoip" : {
"dynamic" : true,
"properties" : {
"ip" : {
"type" : "ip"
},
"latitude" : {
"type" : "half_float"
},
"location" : {
"type" : "geo_point"
},
"longitude" : {
"type" : "half_float"
}}
},
"@version" : {
"type" : "keyword"
}}
},
"aliases" : { }
}
  • 以上的模板接管了 filebeat-* 开头的 index,然后将策略应用于这些 index

    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-4FBy13zS-1656385174090)(https://upload-images.jianshu.io/upload_images/19745945-0a0d70bed3880315.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)]
  • 现在我们就可以在 index management 里查看索引当前的生命周期状态

38.2 index生命周期管理设置

  • cluster级别设置
    • indices.lifecycle.history_index_enabled( Static , Boolean) 是否启用 ILM 的历史index
      • 默认为true.
    • indices.lifecycle.poll_interval(Dynamic, time unit value)index生命周期管理检查符合策略标准的index的频率
      • 默认为10m
  • index级别设置
    • 这些index级 ILM 设置通常通过index模板进行配置
      • index.lifecycle.indexing_complete( Dynamic , Boolean) 指示index是否已rollover
      • index.lifecycle.name( Dynamic , string) 用于管理index的策略名称
      • index.lifecycle.origination_date( Dynamic , long) 如果指定,这是用于计算其阶段转换的index age的时间戳
      • index.lifecycle.parse_origination_date( Dynamic , Boolean) 设置为true从index名称解析起始日期
  • index级别设置
    • index.lifecycle.step.wait_time_threshold(Dynamic, time value)在 ILM shrink操作期间等待cluster解决分配问题的时间
      • 必须大于1h(1 小时)
      • 默认为 12h(12 小时)
    • index.lifecycle.rollover_alias( Dynamic , string) index rollover时要更新的index别名
      • 指定何时使用包含rollover操作的策略
      • 当index rollover时,别名被更新以反映该index不再是写index

大数据视频推荐:
CSDN
大数据语音推荐:
ELK7 stack开发运维
企业级大数据技术应用
大数据机器学习案例之推荐系统
自然语言处理
大数据基础
人工智能:深度学习入门到精通

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值