2018-10-16 15:18:54 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
|
|
|
[[ilm-put-lifecycle]]
|
2018-11-08 18:26:27 -05:00
|
|
|
=== Create Lifecycle Policy API
|
2018-10-16 15:18:54 -04:00
|
|
|
++++
|
2018-11-08 18:26:27 -05:00
|
|
|
<titleabbrev>Create Policy</titleabbrev>
|
2018-10-16 15:18:54 -04:00
|
|
|
++++
|
|
|
|
|
2018-11-16 13:49:55 -05:00
|
|
|
beta[]
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
Creates or updates lifecycle policy.
|
2018-10-16 15:18:54 -04:00
|
|
|
|
|
|
|
==== Request
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
`PUT _ilm/policy/<policy_id>`
|
2018-10-16 15:18:54 -04:00
|
|
|
|
|
|
|
==== Description
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
Creates a lifecycle policy. If the specified policy exists, the policy is
|
|
|
|
replaced and the policy version is incremented.
|
2018-10-16 15:18:54 -04:00
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
NOTE: Only the latest version of the policy is stored, you cannot revert to
|
|
|
|
previous versions.
|
2018-10-16 15:18:54 -04:00
|
|
|
|
|
|
|
==== Path Parameters
|
|
|
|
|
|
|
|
`policy` (required)::
|
|
|
|
(string) Identifier for the policy.
|
|
|
|
|
|
|
|
==== Request Parameters
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
include::{docdir}/rest-api/timeoutparms.asciidoc[]
|
2018-10-16 15:18:54 -04:00
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
==== Authorization
|
2018-10-16 15:18:54 -04:00
|
|
|
|
2018-12-18 12:53:25 -05:00
|
|
|
You must have the `manage_ilm` cluster privilege to use this API. You must
|
|
|
|
also have the `manage` index privilege on all indices being managed by `policy`.
|
|
|
|
All operations executed by {Ilm} for a policy are executed as the user that
|
|
|
|
put the latest version of a policy.
|
|
|
|
For more information, see {stack-ov}/security-privileges.html[Security Privileges].
|
2018-10-16 15:18:54 -04:00
|
|
|
|
|
|
|
==== Examples
|
|
|
|
|
|
|
|
The following example creates a new policy named `my_policy`:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-10-30 19:19:05 -04:00
|
|
|
PUT _ilm/policy/my_policy
|
2018-10-16 15:18:54 -04:00
|
|
|
{
|
|
|
|
"policy": {
|
|
|
|
"phases": {
|
|
|
|
"warm": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "10d",
|
2018-10-16 15:18:54 -04:00
|
|
|
"actions": {
|
|
|
|
"forcemerge": {
|
|
|
|
"max_num_segments": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"delete": {
|
2018-10-30 15:54:02 -04:00
|
|
|
"min_age": "30d",
|
2018-10-16 15:18:54 -04:00
|
|
|
"actions": {
|
|
|
|
"delete": {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
|
|
|
// TEST
|
|
|
|
|
2018-11-08 18:26:27 -05:00
|
|
|
If the request succeeds, you receive the following result:
|
2018-10-16 15:18:54 -04:00
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"acknowledged": true
|
|
|
|
}
|
|
|
|
----
|
|
|
|
// CONSOLE
|
|
|
|
// TESTRESPONSE
|