How do I add a lifecycle policy to an index via the API?

In Kibana, if I click on an index, and then click the Manage button, I have the option to "Add lifecycle policy" to that existing index - I'm asked for the policy to add and the rollover index.

How do I do this via the API?

I see documentation on how to remove a policy but nothing on how to add one.

Thanks!

Isn't this page?

Thanks for getting back to me. I just updated my question to make it clearer - that page describes how to add a life cycle policy. I'm trying to figure out how to add an existing lifecycle policy to an existing index

It's an index settings. So you need to call the update index settings API or the index template API. Of course this also works with the create index API.

See https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-settings.html#_index_level_settings

Specifically index.lifecycle.name.

1 Like

Thank you!! That looks like it's exactly what I need.

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