get-lifecycle.asciidoc 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-get-lifecycle]]
  4. === Get Lifecycle Policy API
  5. ++++
  6. <titleabbrev>Get Policy</titleabbrev>
  7. ++++
  8. beta[]
  9. Retrieves a lifecycle policy.
  10. ==== Request
  11. `GET _ilm/policy`
  12. `GET _ilm/policy/<policy_id>`
  13. ==== Description
  14. Returns the specified policy definition. Includes the policy version and last
  15. modified date. If no policy is specified, returns all defined policies.
  16. ==== Path Parameters
  17. `policy` (optional)::
  18. (string) Identifier for the policy.
  19. ==== Request Parameters
  20. include::{docdir}/rest-api/timeoutparms.asciidoc[]
  21. ==== Authorization
  22. You must have the `manage_ilm` or `read_ilm` or both cluster privileges to use this API.
  23. For more information, see {stack-ov}/security-privileges.html[Security Privileges].
  24. ==== Examples
  25. The following example retrieves `my_policy`:
  26. //////////////////////////
  27. [source,js]
  28. --------------------------------------------------
  29. PUT _ilm/policy/my_policy
  30. {
  31. "policy": {
  32. "phases": {
  33. "warm": {
  34. "min_age": "10d",
  35. "actions": {
  36. "forcemerge": {
  37. "max_num_segments": 1
  38. }
  39. }
  40. },
  41. "delete": {
  42. "min_age": "30d",
  43. "actions": {
  44. "delete": {}
  45. }
  46. }
  47. }
  48. }
  49. }
  50. --------------------------------------------------
  51. // CONSOLE
  52. // TEST
  53. //////////////////////////
  54. [source,js]
  55. --------------------------------------------------
  56. GET _ilm/policy
  57. --------------------------------------------------
  58. // CONSOLE
  59. // TEST[continued]
  60. If the request succeeds, the body of the response contains the policy definition:
  61. [source,js]
  62. --------------------------------------------------
  63. {
  64. "my_policy": {
  65. "version": 1, <1>
  66. "modified_date": 82392349, <2>
  67. "policy": {
  68. "phases": {
  69. "warm": {
  70. "min_age": "10d",
  71. "actions": {
  72. "forcemerge": {
  73. "max_num_segments": 1
  74. }
  75. }
  76. },
  77. "delete": {
  78. "min_age": "30d",
  79. "actions": {
  80. "delete": {}
  81. }
  82. }
  83. }
  84. }
  85. }
  86. }
  87. --------------------------------------------------
  88. // CONSOLE
  89. // TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
  90. <1> The policy version is incremented whenever the policy is updated
  91. <2> When this policy was last modified