get-lifecycle.asciidoc 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[ilm-get-lifecycle]]
  4. === Get Lifecycle Policy API
  5. ++++
  6. <titleabbrev>Get Policy</titleabbrev>
  7. ++++
  8. Retrieves an existing policy
  9. ==== Request
  10. `GET _ilm/policy`
  11. `GET _ilm/policy/<policy>`
  12. ==== Description
  13. This API returns a policy definition along with some of its metadata like
  14. its last modified date and version. If no path parameters are provided, then
  15. all the policies defined will be returned.
  16. ==== Path Parameters
  17. `policy` (optional)::
  18. (string) Identifier for the policy.
  19. ==== Request Parameters
  20. `timeout`::
  21. (time units) Specifies the period of time to wait for the completion of the
  22. GET operation. When this period of time elapses, the API fails and returns
  23. an error. The default value is `30s`. For more information about time units,
  24. see <<time-units>>.
  25. `master_timeout`::
  26. (time units) Specifies the period of time to wait for the connection with master.
  27. When this period of time elapses, the API fails and returns an error.
  28. The default value is `30s`. For more information about time units, see <<time-units>>.
  29. ==== Examples
  30. The following example retrieves the policy named `my_policy`:
  31. //////////////////////////
  32. [source,js]
  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. // CONSOLE
  57. // TEST
  58. //////////////////////////
  59. [source,js]
  60. --------------------------------------------------
  61. GET _ilm/policy
  62. --------------------------------------------------
  63. // CONSOLE
  64. // TEST[continued]
  65. If the request does not encounter errors, you receive the following result:
  66. [source,js]
  67. --------------------------------------------------
  68. {
  69. "my_policy": {
  70. "version": 1, <1>
  71. "modified_date": 82392349, <2>
  72. "policy": {
  73. "phases": {
  74. "warm": {
  75. "min_age": "10d",
  76. "actions": {
  77. "forcemerge": {
  78. "max_num_segments": 1
  79. }
  80. }
  81. },
  82. "delete": {
  83. "min_age": "30d",
  84. "actions": {
  85. "delete": {}
  86. }
  87. }
  88. }
  89. }
  90. }
  91. }
  92. --------------------------------------------------
  93. // CONSOLE
  94. // TESTRESPONSE[s/"modified_date": 82392349/"modified_date": $body.my_policy.modified_date/]
  95. <1> The version of the policy. This is increased whenever the policy is updated
  96. <2> The timestamp when this policy was last modified