configure TTL in elastic search with index template

北战南征 提交于 2019-12-12 04:12:38

问题


I have requirement to only store data for 10 days in elastic search which is coming through logstash. As I don't have too much data so I am taking approach for setting up TTL through index template.

Could anybody let me know what is exactly I have to do.

I can go for creation of index template and in template file I have kept the following code in default.json file

{
   "_ttl" : {
    "enabled" : true,
    "default" : "10d"
 }  
}

But I am not sure where to keep this file and how that file is getting called. will it get called automatically or will I have to call manually.

Could anybody Please let me know the step by step configuration.


回答1:


The _ttl field has been deprecated in ES 2 and completely removed in ES 5.

What you should do instead is to use one index per timeframe (day, week, month) that makes sense for your use case.

In Logstash, simply use the following pattern for naming your index "logstash-%{+YYYY.MM.dd}" in your elasticsearch output.

Once you have that set up you can use the curator tool to delete indices older than 10 days, it's pretty straightforward.



来源:https://stackoverflow.com/questions/40945275/configure-ttl-in-elastic-search-with-index-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!