1
0

get-lifecycle.asciidoc 2.9 KB

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