Elasticsearch API to add a lifecycle policy to an index template

index-lifecycle-management

(Matt Russell) #1

Is there a way to update an index template to add a lifecycle policy through Elasticsearch APIs (to achieve the same effect as can be done in Kibana)?


(Lee Hinman) #2

Hi Matt,

The only way you would do this with a template is to retrieve the template with

GET /_template/my-template

Then add the index.lifecycle.name setting to what already existed in the body of the template, and then update the template

PUT /_template/my-template
{
  "settings": {
    <... the rest of your template's settings ...>
    "index.lifecycle.name": "delete-old-logs"
  }
}

(Matt Russell) #3

Thanks Lee - yeah, so I guess this is a bit awkward to script at present.


(system) closed #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.