slm-get.asciidoc 3.6 KB

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