get-lifecycle.asciidoc 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. [role="xpack"]
  2. [[ilm-get-lifecycle]]
  3. === Get lifecycle policy API
  4. ++++
  5. <titleabbrev>Get policy</titleabbrev>
  6. ++++
  7. Retrieves a lifecycle policy.
  8. [[ilm-get-lifecycle-request]]
  9. ==== {api-request-title}
  10. `GET _ilm/policy`
  11. `GET _ilm/policy/<policy_id>`
  12. [[ilm-get-lifecycle-prereqs]]
  13. ==== {api-prereq-title}
  14. * If the {es} {security-features} are enabled, you must have the `manage_ilm` or
  15. `read_ilm` or both cluster privileges to use this API. For more information, see
  16. <<security-privileges>>.
  17. [[ilm-get-lifecycle-desc]]
  18. ==== {api-description-title}
  19. Returns the specified policy definition. Includes the policy version and last
  20. modified date. If no policy is specified, returns all defined policies.
  21. [[ilm-get-lifecycle-path-params]]
  22. ==== {api-path-parms-title}
  23. `<policy_id>`::
  24. (Optional, string) Identifier for the policy.
  25. [[ilm-get-lifecycle-query-params]]
  26. ==== {api-query-parms-title}
  27. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  28. [[ilm-get-lifecycle-example]]
  29. ==== {api-examples-title}
  30. The following example retrieves `my_policy`:
  31. //////////////////////////
  32. [source,console]
  33. --------------------------------------------------
  34. PUT _ilm/policy/my_policy
  35. {
  36. "policy": {
  37. "phases": {
  38. "warm": {
  39. "min_age": "10d",
  40. "actions": {
  41. "forcemerge": {
  42. "max_num_segments": 1
  43. }
  44. }
  45. },
  46. "delete": {
  47. "min_age": "30d",
  48. "actions": {
  49. "delete": {}
  50. }
  51. }
  52. }
  53. }
  54. }
  55. --------------------------------------------------
  56. //////////////////////////
  57. [source,console]
  58. --------------------------------------------------
  59. GET _ilm/policy/my_policy
  60. --------------------------------------------------
  61. // TEST[continued]
  62. If the request succeeds, the body of the response contains the policy definition:
  63. [source,console-result]
  64. --------------------------------------------------
  65. {
  66. "my_policy": {
  67. "version": 1, <1>
  68. "modified_date": 82392349, <2>
  69. "policy": {
  70. "phases": {
  71. "warm": {
  72. "min_age": "10d",
  73. "actions": {
  74. "forcemerge": {
  75. "max_num_segments": 1
  76. }
  77. }
  78. },
  79. "delete": {
  80. "min_age": "30d",
  81. "actions": {
  82. "delete": {
  83. "delete_searchable_snapshot": true
  84. }
  85. }
  86. }
  87. }
  88. },
  89. "in_use_by" : { <3>
  90. "indices" : [],
  91. "data_streams" : [],
  92. "composable_templates" : []
  93. }
  94. }
  95. }
  96. --------------------------------------------------
  97. // TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
  98. <1> The policy version is incremented whenever the policy is updated
  99. <2> When this policy was last modified
  100. <3> Which indices, data streams, or templates currently use this policy