2018-10-26 15:19:52 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
2018-08-13 16:15:15 -04:00
|
|
|
[[update-lifecycle-policy]]
|
2018-11-08 18:26:27 -05:00
|
|
|
== Update Lifecycle Policy
|
|
|
|
++++
|
|
|
|
<titleabbrev>Update Policy</titleabbrev>
|
|
|
|
++++
|
2018-08-13 16:15:15 -04:00
|
|
|
|
2018-11-16 13:49:55 -05:00
|
|
|
beta[]
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
You can update an existing lifecycle policy to fix mistakes or change
|
2018-10-25 18:24:25 -04:00
|
|
|
strategies for newly created indices. It is possible to update policy definitions
|
|
|
|
and an index's `index.lifecycle.name` settings independently. To prevent the situation
|
|
|
|
that phase definitions are modified while currently being executed on an index, each index
|
|
|
|
will keep the version of the current phase definition it began execution with until it completes.
|
|
|
|
|
|
|
|
There are three scenarios for examining the behavior updating policies and
|
|
|
|
their effects on policy execution on indices.
|
|
|
|
|
|
|
|
=== Updates to policies not managing indices
|
|
|
|
|
2018-11-16 13:49:55 -05:00
|
|
|
beta[]
|
|
|
|
|
2018-10-25 18:24:25 -04:00
|
|
|
Indices not referencing an existing policy that is updated will not be affected.
|
|
|
|
If an index is assigned to the policy, it will be assigned the latest version of that policy
|
|
|
|
|
|
|
|
To show this, let's create a policy `my_policy`.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"hot": {
|
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_size": "25GB"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "30d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
This newly defined policy will be created and assigned to have a version equal
|
|
|
|
to 1. Since we haven't assigned any indices to this policy, any updates that
|
|
|
|
occur will be reflected completely on indices that are newly set to be managed
|
|
|
|
by this policy.
|
|
|
|
|
|
|
|
Updating the Delete phase's minimum age can be done in an update request.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"hot": {
|
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_size": "25GB"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d", <1>
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
2018-10-30 15:54:02 -04:00
|
|
|
<1> update `min_age` to 10 days
|
2018-10-25 18:24:25 -04:00
|
|
|
|
|
|
|
//////////
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
GET _ilm/policy
|
2018-10-25 18:24:25 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
//////////
|
|
|
|
|
|
|
|
When we get the policy, we will see it reflect our latest changes, but
|
|
|
|
with its version bumped to 2.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"my_policy": {
|
|
|
|
"version": 2, <1>
|
|
|
|
"modified_date": 82392349, <2>
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"hot": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "0ms",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_size": "25gb"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
|
|
|
|
<1> The updated version value
|
|
|
|
<2> The timestamp when this policy was updated last.
|
|
|
|
|
|
|
|
Afterwords, any indices set to `my_policy` will execute against version 2 of
|
|
|
|
the policy.
|
|
|
|
|
|
|
|
=== Updates to executing policies
|
|
|
|
|
2018-11-16 13:49:55 -05:00
|
|
|
beta[]
|
|
|
|
|
2018-10-25 18:24:25 -04:00
|
|
|
Indices preserve the phase definition from the latest policy version that existed
|
|
|
|
at the time that it entered that phase. Changes to the currently-executing phase within policy updates will
|
|
|
|
not be reflected during execution. This means that updates to the `hot` phase, for example, will not affect
|
|
|
|
indices that are currently executing the corresponding `hot` phase.
|
|
|
|
|
|
|
|
Let's say we have an index `my_index` managed by the below `my_executing_policy` definition.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_executing_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"hot": {
|
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_docs": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
////
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"settings": {
|
|
|
|
"index.lifecycle.name": "my_executing_policy"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
////
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
The <<ilm-explain-lifecycle,Explain API>> is useful to introspect managed indices to see which phase definition they are currently executing.
|
2018-11-15 19:11:31 -05:00
|
|
|
Using this API, we can find out that `my_index` is currently checking if it is ready to be rolled over.
|
2018-10-25 18:24:25 -04:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET my_index/_ilm/explain
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"indices": {
|
|
|
|
"my_index": {
|
|
|
|
"index": "my_index",
|
|
|
|
"managed": true,
|
|
|
|
"policy": "my_executing_policy",
|
2018-11-05 10:17:15 -05:00
|
|
|
"lifecycle_date_millis": 1538475653281,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase": "hot",
|
2018-11-05 10:17:15 -05:00
|
|
|
"phase_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"action": "rollover",
|
2018-11-05 10:17:15 -05:00
|
|
|
"action_time_millis": 1538475653317,
|
2018-11-15 19:11:31 -05:00
|
|
|
"step": "check-rollover-ready",
|
2018-11-05 10:17:15 -05:00
|
|
|
"step_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase_execution": {
|
|
|
|
"policy": "my_executing_policy",
|
|
|
|
"modified_date_in_millis": 1538475653317,
|
|
|
|
"version": 1,
|
|
|
|
"phase_definition": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "0ms",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_docs": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
2018-11-14 19:45:06 -05:00
|
|
|
// TESTRESPONSE[skip:no way to know if we will get this response immediately]
|
2018-10-25 18:24:25 -04:00
|
|
|
|
|
|
|
Updating `my_executing_policy` to have no rollover action and, instead, go directly into a newly introduced `warm` phase.
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_executing_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"warm": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "1d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"forcemerge": {
|
|
|
|
"max_num_segments": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
Now, version 2 of this policy has no `hot` phase, but if we run the Explain API again, we will see that nothing has changed.
|
|
|
|
The index `my_index` is still executing version 1 of the policy.
|
|
|
|
|
|
|
|
////
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
GET my_index/_ilm/explain
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
////
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"indices": {
|
|
|
|
"my_index": {
|
|
|
|
"index": "my_index",
|
|
|
|
"managed": true,
|
|
|
|
"policy": "my_executing_policy",
|
2018-11-05 10:17:15 -05:00
|
|
|
"lifecycle_date_millis": 1538475653281,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase": "hot",
|
2018-11-05 10:17:15 -05:00
|
|
|
"phase_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"action": "rollover",
|
2018-11-05 10:17:15 -05:00
|
|
|
"action_time_millis": 1538475653317,
|
2018-11-15 19:11:31 -05:00
|
|
|
"step": "check-rollover-ready",
|
2018-11-05 10:17:15 -05:00
|
|
|
"step_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase_execution": {
|
|
|
|
"policy": "my_executing_policy",
|
|
|
|
"modified_date_in_millis": 1538475653317,
|
|
|
|
"version": 1,
|
|
|
|
"phase_definition": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "0ms",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_docs": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
2018-11-25 20:19:17 -05:00
|
|
|
// TESTRESPONSE[skip:no way to know if we will get this response immediately]
|
2018-10-25 18:24:25 -04:00
|
|
|
|
|
|
|
After indexing one document into `my_index` so that rollover succeeds and moves onto the next phase, we will notice something new. The
|
|
|
|
index will move into the next phase in the updated version 2 of its policy.
|
|
|
|
|
|
|
|
////
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT my_index/_doc/1
|
|
|
|
{
|
|
|
|
"foo": "bar"
|
|
|
|
}
|
|
|
|
|
|
|
|
GET my_index/_ilm/explain
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
////
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"indices": {
|
|
|
|
"my_index": {
|
|
|
|
"index": "my_index",
|
|
|
|
"managed": true,
|
|
|
|
"policy": "my_executing_policy",
|
2018-11-05 10:17:15 -05:00
|
|
|
"lifecycle_date_millis": 1538475653281,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase": "warm",
|
2018-11-05 10:17:15 -05:00
|
|
|
"phase_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"action": "forcemerge",
|
2018-11-05 10:17:15 -05:00
|
|
|
"action_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"step": "forcemerge",
|
2018-11-05 10:17:15 -05:00
|
|
|
"step_time_millis": 1538475653317,
|
2018-10-25 18:24:25 -04:00
|
|
|
"phase_execution": {
|
|
|
|
"policy": "my_executing_policy",
|
|
|
|
"modified_date_in_millis": 1538475653317,
|
|
|
|
"version": 2, <1>
|
|
|
|
"phase_definition": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "1d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"forcemerge": {
|
|
|
|
"max_num_segments": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TESTRESPONSE[skip:There is no way to force the index to move to the next step in a timely manner]
|
|
|
|
<1> The index has moved to using version 2 of the policy
|
|
|
|
|
|
|
|
`my_index` will move to the next phase in the latest policy definition, which is the newly added `warm` phase.
|
|
|
|
|
|
|
|
=== Switching policies for an index
|
|
|
|
|
2018-11-16 13:49:55 -05:00
|
|
|
beta[]
|
|
|
|
|
2018-10-25 18:24:25 -04:00
|
|
|
Setting `index.lifecycle.name` to a different policy behaves much like a policy update, but instead of just
|
|
|
|
switching to a different version, it switches to a different policy.
|
|
|
|
|
|
|
|
After setting a policy for an index, we can switch out `my_policy` with
|
|
|
|
`my_other_policy` by just updating the index's `index.lifecycle.name`
|
|
|
|
setting to the new policy. After completing its currently executed phase,
|
|
|
|
it will move on to the next phase in `my_other_policy`. So if it was on the
|
|
|
|
`hot` phase before, it will move to the `delete` phase after the `hot` phase concluded.
|
|
|
|
|
|
|
|
////
|
|
|
|
[source,js]
|
|
|
|
------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"hot": {
|
|
|
|
"actions": {
|
|
|
|
"rollover": {
|
|
|
|
"max_size": "25GB"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_other_policy
|
2018-10-25 18:24:25 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "1d",
|
2018-10-25 18:24:25 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"settings": {
|
|
|
|
"index.lifecycle.name": "my_policy"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
------------------------
|
|
|
|
// CONSOLE
|
|
|
|
|
|
|
|
////
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
|
|
|
PUT my_index/_settings
|
|
|
|
{
|
|
|
|
"lifecycle.name": "my_other_policy"
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
The change to the new policy will not happen immediately. The currently executing phase
|
|
|
|
of the existing policy for `my_index` will continue to execute until it completes. Once
|
|
|
|
completed, `my_index` will move to being managed by the `my_other_policy`.
|