slm-get.asciidoc 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[slm-api-get-policy]]
  4. === Get snapshot lifecycle policy API
  5. ++++
  6. <titleabbrev>Get policy</titleabbrev>
  7. ++++
  8. Retrieves one or more snapshot lifecycle policy definitions and
  9. information about the latest snapshot attempts.
  10. [[slm-api-get-request]]
  11. ==== {api-request-title}
  12. `GET /_slm/policy/<policy-id>`
  13. `GET /_slm/policy`
  14. [[slm-api-get-lifecycle-prereqs]]
  15. ==== {api-prereq-title}
  16. If the {es} {security-features} are enabled, you must have the `manage_slm`
  17. cluster privilege to use this API. For more information, see
  18. <<security-privileges>>.
  19. [[slm-api-get-desc]]
  20. ==== {api-description-title}
  21. Returns the specified policy definition and
  22. information about the latest successful and failed attempts to create snapshots.
  23. If no policy is specified, returns all defined policies.
  24. [[slm-api-get-path-params]]
  25. ==== {api-path-parms-title}
  26. `<policy-id>`::
  27. (Optional, string)
  28. Comma-separated list of snapshot lifecycle policy IDs.
  29. [[slm-api-get-example]]
  30. ==== {api-examples-title}
  31. [[slm-api-get-specific-ex]]
  32. ===== Get a specific policy
  33. ////
  34. [source,console]
  35. --------------------------------------------------
  36. PUT /_slm/policy/daily-snapshots
  37. {
  38. "schedule": "0 30 1 * * ?", <1>
  39. "name": "<daily-snap-{now/d}>", <2>
  40. "repository": "my_repository", <3>
  41. "config": { <4>
  42. "indices": ["data-*", "important"], <5>
  43. "ignore_unavailable": false,
  44. "include_global_state": false
  45. },
  46. "retention": { <6>
  47. "expire_after": "30d", <7>
  48. "min_count": 5, <8>
  49. "max_count": 50 <9>
  50. }
  51. }
  52. --------------------------------------------------
  53. // TEST[setup:setup-repository]
  54. ////
  55. Get the `daily-snapshots` policy:
  56. [source,console]
  57. --------------------------------------------------
  58. GET /_slm/policy/daily-snapshots?human
  59. --------------------------------------------------
  60. // TEST[continued]
  61. This request returns the following response:
  62. [source,console-result]
  63. --------------------------------------------------
  64. {
  65. "daily-snapshots" : {
  66. "version": 1, <1>
  67. "modified_date": "2019-04-23T01:30:00.000Z", <2>
  68. "modified_date_millis": 1556048137314,
  69. "policy" : {
  70. "schedule": "0 30 1 * * ?",
  71. "name": "<daily-snap-{now/d}>",
  72. "repository": "my_repository",
  73. "config": {
  74. "indices": ["data-*", "important"],
  75. "ignore_unavailable": false,
  76. "include_global_state": false
  77. },
  78. "retention": {
  79. "expire_after": "30d",
  80. "min_count": 5,
  81. "max_count": 50
  82. }
  83. },
  84. "stats": {
  85. "policy": "daily-snapshots",
  86. "snapshots_taken": 0,
  87. "snapshots_failed": 0,
  88. "snapshots_deleted": 0,
  89. "snapshot_deletion_failures": 0
  90. },
  91. "next_execution": "2019-04-24T01:30:00.000Z", <3>
  92. "next_execution_millis": 1556048160000
  93. }
  94. }
  95. --------------------------------------------------
  96. // TESTRESPONSE[s/"modified_date": "2019-04-23T01:30:00.000Z"/"modified_date": $body.daily-snapshots.modified_date/ s/"modified_date_millis": 1556048137314/"modified_date_millis": $body.daily-snapshots.modified_date_millis/ s/"next_execution": "2019-04-24T01:30:00.000Z"/"next_execution": $body.daily-snapshots.next_execution/ s/"next_execution_millis": 1556048160000/"next_execution_millis": $body.daily-snapshots.next_execution_millis/]
  97. <1> The version of the snapshot policy, only the latest verison is stored and incremented when the policy is updated
  98. <2> The last time this policy was modified.
  99. <3> The next time this policy will be executed.
  100. [[slm-api-get-all-ex]]
  101. ===== Get all policies
  102. [source,console]
  103. --------------------------------------------------
  104. GET /_slm/policy
  105. --------------------------------------------------
  106. // TEST[continued]