elasticsearch/docs/reference/ilm/apis/put-lifecycle.asciidoc
Liam Thompson 33a71e3289
[DOCS] Refactor book-scoped variables in docs/reference/index.asciidoc (#107413)
* Remove `es-test-dir` book-scoped variable

* Remove `plugins-examples-dir` book-scoped variable

* Remove `:dependencies-dir:` and `:xes-repo-dir:` book-scoped variables

- In `index.asciidoc`, two variables (`:dependencies-dir:` and `:xes-repo-dir:`) were removed.
- In `sql/index.asciidoc`, the `:sql-tests:` path was updated to fuller path
- In `esql/index.asciidoc`, the `:esql-tests:` path was updated idem

* Replace `es-repo-dir` with `es-ref-dir`

* Move `:include-xpack: true` to few files that use it, remove from index.asciidoc
2024-04-17 14:37:07 +02:00

98 lines
2.6 KiB
Text

[role="xpack"]
[[ilm-put-lifecycle]]
=== Create or update lifecycle policy API
++++
<titleabbrev>Create or update lifecycle policy</titleabbrev>
++++
Creates or updates lifecycle policy. See <<ilm-index-lifecycle>> for
definitions of policy components.
[[ilm-put-lifecycle-request]]
==== {api-request-title}
`PUT _ilm/policy/<policy_id>`
[[ilm-put-lifecycle-prereqs]]
==== {api-prereq-title}
* If the {es} {security-features} are enabled, 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`. {ilm-init} performs
operations as the user who last updated the policy. {ilm-init} only has the
<<defining-roles,roles>> assigned to the user at the time of the last policy
update.
[[ilm-put-lifecycle-desc]]
==== {api-description-title}
Creates a lifecycle policy. If the specified policy exists, the policy is
replaced and the policy version is incremented.
NOTE: Only the latest version of the policy is stored, you cannot revert to
previous versions.
[[ilm-put-lifecycle-path-params]]
==== {api-path-parms-title}
`<policy_id>`::
(Required, string) Identifier for the policy.
+
[IMPORTANT]
====
To avoid naming collisions with built-in and Fleet-managed ILM policies, avoid using `@` as part of the id of your own ILM policies.
====
[[ilm-put-lifecycle-query-params]]
==== {api-query-parms-title}
include::{es-ref-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
[[ilm-put-lifecycle-example]]
==== {api-examples-title}
The following example creates a new policy named `my_policy`. In addition, you can use the
`_meta` parameter to add arbitrary metadata to the policy, the `_meta` parameter is optional
and not automatically generated or used by Elasticsearch. To unset `_meta`, replace the policy
without specifying one. To check the `_meta`, you can use the <<ilm-get-lifecycle,Get lifecycle policy>> API.
[source,console]
--------------------------------------------------
PUT _ilm/policy/my_policy
{
"policy": {
"_meta": {
"description": "used for nginx log",
"project": {
"name": "myProject",
"department": "myDepartment"
}
},
"phases": {
"warm": {
"min_age": "10d",
"actions": {
"forcemerge": {
"max_num_segments": 1
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {}
}
}
}
}
}
--------------------------------------------------
If the request succeeds, you receive the following result:
[source,console-result]
----
{
"acknowledged": true
}
----