put-lifecycle.asciidoc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-put-lifecycle]]
  4. === Create lifecycle policy API
  5. ++++
  6. <titleabbrev>Create policy</titleabbrev>
  7. ++++
  8. Creates or updates lifecycle policy. See <<ilm-policy-definition>> for
  9. definitions of policy components.
  10. [[ilm-put-lifecycle-request]]
  11. ==== {api-request-title}
  12. `PUT _ilm/policy/<policy_id>`
  13. [[ilm-put-lifecycle-prereqs]]
  14. ==== {api-prereq-title}
  15. * If the {es} {security-features} are enabled, you must have the `manage_ilm`
  16. cluster privilege to use this API. You must also have the `manage` index
  17. privilege on all indices being managed by `policy`. All operations executed by
  18. {ilm} for a policy are executed as the user that put the latest version of a
  19. policy. For more information, see <<security-privileges>>.
  20. [[ilm-put-lifecycle-desc]]
  21. ==== {api-description-title}
  22. Creates a lifecycle policy. If the specified policy exists, the policy is
  23. replaced and the policy version is incremented.
  24. NOTE: Only the latest version of the policy is stored, you cannot revert to
  25. previous versions.
  26. [[ilm-put-lifecycle-path-params]]
  27. ==== {api-path-parms-title}
  28. `<policy_id>`::
  29. (Required, string) Identifier for the policy.
  30. [[ilm-put-lifecycle-query-params]]
  31. ==== {api-query-parms-title}
  32. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  33. [[ilm-put-lifecycle-example]]
  34. ==== {api-examples-title}
  35. The following example creates a new policy named `my_policy`:
  36. [source,console]
  37. --------------------------------------------------
  38. PUT _ilm/policy/my_policy
  39. {
  40. "policy": {
  41. "phases": {
  42. "warm": {
  43. "min_age": "10d",
  44. "actions": {
  45. "forcemerge": {
  46. "max_num_segments": 1
  47. }
  48. }
  49. },
  50. "delete": {
  51. "min_age": "30d",
  52. "actions": {
  53. "delete": {}
  54. }
  55. }
  56. }
  57. }
  58. }
  59. --------------------------------------------------
  60. If the request succeeds, you receive the following result:
  61. [source,console-result]
  62. ----
  63. {
  64. "acknowledged": true
  65. }
  66. ----