slm-api.asciidoc 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[snapshot-lifecycle-management-api]]
  4. == Snapshot lifecycle management API
  5. The Snapshot Lifecycle Management APIs are used to manage policies for the time
  6. and frequency of automatic snapshots. Snapshot Lifecycle Management is related
  7. to <<index-lifecycle-management,Index Lifecycle Management>>, however, instead
  8. of managing a lifecycle of actions that are performed on a single index, SLM
  9. allows configuring policies spanning multiple indices. Snapshot Lifecycle
  10. Management can also perform deletion of older snapshots based on a configurable
  11. retention policy.
  12. SLM policy management is split into three different CRUD APIs, a way to put or update
  13. policies, a way to retrieve policies, and a way to delete unwanted policies, as
  14. well as a separate API for immediately invoking a snapshot based on a policy.
  15. Since SLM falls under the same category as ILM, it is stopped and started by
  16. using the <<start-stop-ilm,start and stop>> ILM APIs. It is, however, managed
  17. by a different enable setting. To disable SLM's functionality, set the cluster
  18. setting `xpack.slm.enabled` to `false` in elasticsearch.yml.
  19. [[slm-api-put]]
  20. === Put snapshot lifecycle policy API
  21. ++++
  22. <titleabbrev>Put snapshot lifecycle policy</titleabbrev>
  23. ++++
  24. Creates or updates a snapshot lifecycle policy.
  25. [[slm-api-put-request]]
  26. ==== {api-request-title}
  27. `PUT /_slm/policy/<snapshot-lifecycle-policy-id>`
  28. [[slm-api-put-prereqs]]
  29. ==== {api-prereq-title}
  30. If you use {es} {security-features},
  31. you must have:
  32. * `manage_slm` <<privileges-list-cluster,cluster privileges>>
  33. * `manage` <<privileges-list-indices,index privileges>> for any included indices
  34. {slm-cap} operations are executed
  35. as the user that last created or updated the policy.
  36. For more information,
  37. see <<security-privileges>>.
  38. [[slm-api-put-desc]]
  39. ==== {api-description-title}
  40. Use the put snapshot lifecycle policy API
  41. to create or update a snapshot lifecycle policy.
  42. If the policy already exists,
  43. this request increments the policy's version.
  44. Only the latest version of the policy is stored.
  45. [[slm-api-put-path-params]]
  46. ==== {api-path-parms-title}
  47. `<snapshot-lifecycle-policy-id>`::
  48. (Required, string)
  49. ID for the snapshot lifecycle policy
  50. you want to create or update.
  51. [[slm-api-put-query-params]]
  52. ==== {api-query-parms-title}
  53. include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
  54. [[slm-api-put-request-body]]
  55. ==== {api-request-body-title}
  56. `schedule`::
  57. (Required, <<schedule-cron,Cron scheduler configuration>>)
  58. Periodic or absolute schedule
  59. at which the policy creates snapshots
  60. and deletes expired snapshots.
  61. +
  62. Schedule changes to existing policies
  63. are applied immediately.
  64. `name`::
  65. +
  66. --
  67. (Required, string)
  68. Name automatically assigned to each snapshot
  69. created by the policy.
  70. This value supports the same <<date-math-index-names,date math>>
  71. supported in index names.
  72. To prevent conflicting snapshot names,
  73. a UUID is automatically appended to each snapshot name.
  74. --
  75. `repository`::
  76. +
  77. --
  78. (Required, string)
  79. Repository used to store snapshots
  80. created by this policy.
  81. This repository must exist prior to the policy's creation.
  82. You can create a repository
  83. using the <<modules-snapshots,snapshot repository API>>.
  84. --
  85. `config`::
  86. +
  87. --
  88. (Required, object)
  89. Configuration for each snapshot
  90. created by the policy.
  91. Parameters include:
  92. `indices`::
  93. (Optional, array of strings)
  94. Array of index names or wildcard pattern of index names
  95. included in snapshots.
  96. `ignore_unavailable`::
  97. (Optional, boolean)
  98. If `true`,
  99. missing indices do *not* cause snapshot creation to fail
  100. and return an error.
  101. Defaults to `false`.
  102. `include_global_state`::
  103. (Optional, boolean)
  104. If `true`,
  105. cluster states are included in snapshots.
  106. Defaults to `false`.
  107. --
  108. `retention`::
  109. +
  110. --
  111. (Optional, object)
  112. Retention rules used to retain
  113. and delete snapshots
  114. created by the policy.
  115. Parameters include:
  116. `expire_after`::
  117. (Optional, <<time-units, time units>>)
  118. Time period after which
  119. a snapshot is considered expired
  120. and eligible for deletion.
  121. `max_count`::
  122. (Optional, integer)
  123. Maximum number of snapshots to retain,
  124. even if the snapshots have not yet expired.
  125. +
  126. If the number of snapshots in the repository exceeds this limit,
  127. the policy retains the most recent snapshots
  128. and deletes older snapshots.
  129. `min_count`::
  130. (Optional, integer)
  131. Minimum number of snapshots to retain,
  132. even if the snapshots have expired.
  133. --
  134. [[slm-api-put-example]]
  135. ==== {api-examples-title}
  136. The following request creates a snapshot lifecycle policy
  137. with an ID of `daily-snapshots`:
  138. [source,console]
  139. --------------------------------------------------
  140. PUT /_slm/policy/daily-snapshots
  141. {
  142. "schedule": "0 30 1 * * ?", <1>
  143. "name": "<daily-snap-{now/d}>", <2>
  144. "repository": "my_repository", <3>
  145. "config": { <4>
  146. "indices": ["data-*", "important"], <5>
  147. "ignore_unavailable": false,
  148. "include_global_state": false
  149. },
  150. "retention": { <6>
  151. "expire_after": "30d", <7>
  152. "min_count": 5, <8>
  153. "max_count": 50 <9>
  154. }
  155. }
  156. --------------------------------------------------
  157. // TEST[setup:setup-repository]
  158. <1> When the snapshot should be taken, in this case, 1:30am daily
  159. <2> The name each snapshot should be given
  160. <3> Which repository to take the snapshot in
  161. <4> Any extra snapshot configuration
  162. <5> Which indices the snapshot should contain
  163. <6> Optional retention configuration
  164. <7> Keep snapshots for 30 days
  165. <8> Always keep at least 5 successful snapshots, even if they're more than 30 days old
  166. <9> Keep no more than 50 successful snapshots, even if they're less than 30 days old
  167. [[slm-api-get]]
  168. === Get snapshot lifecycle policy API
  169. ++++
  170. <titleabbrev>Get snapshot lifecycle policy</titleabbrev>
  171. ++++
  172. Returns information
  173. about one or more snapshot lifecycle policies.
  174. [[slm-api-get-request]]
  175. ==== {api-request-title}
  176. `GET /_slm/policy/<snapshot-lifecycle-policy-id>`
  177. `GET /_slm/policy/`
  178. [[slm-api-get-desc]]
  179. ==== {api-description-title}
  180. Use the snapshot lifecycle policy API
  181. to retrieve information
  182. about one or more snapshot lifecycle policies.
  183. The API response also includes information
  184. about the latest successful and failed attempts
  185. to create automatic snapshots.
  186. [[slm-api-get-path-params]]
  187. ==== {api-path-parms-title}
  188. `<snapshot-lifecycle-policy-id>`::
  189. (Optional, string)
  190. Comma-separated list of snapshot lifecycle policy IDs
  191. to retrieve.
  192. [[slm-api-get-example]]
  193. ==== {api-examples-title}
  194. [[slm-api-get-specific-ex]]
  195. ===== Get a specific policy
  196. [source,console]
  197. --------------------------------------------------
  198. GET /_slm/policy/daily-snapshots?human
  199. --------------------------------------------------
  200. // TEST[continued]
  201. The API returns the following response:
  202. [source,console-result]
  203. --------------------------------------------------
  204. {
  205. "daily-snapshots" : {
  206. "version": 1, <1>
  207. "modified_date": "2019-04-23T01:30:00.000Z", <2>
  208. "modified_date_millis": 1556048137314,
  209. "policy" : {
  210. "schedule": "0 30 1 * * ?",
  211. "name": "<daily-snap-{now/d}>",
  212. "repository": "my_repository",
  213. "config": {
  214. "indices": ["data-*", "important"],
  215. "ignore_unavailable": false,
  216. "include_global_state": false
  217. },
  218. "retention": {
  219. "expire_after": "30d",
  220. "min_count": 5,
  221. "max_count": 50
  222. }
  223. },
  224. "stats": {
  225. "policy": "daily-snapshots",
  226. "snapshots_taken": 0,
  227. "snapshots_failed": 0,
  228. "snapshots_deleted": 0,
  229. "snapshot_deletion_failures": 0
  230. },
  231. "next_execution": "2019-04-24T01:30:00.000Z", <3>
  232. "next_execution_millis": 1556048160000
  233. }
  234. }
  235. --------------------------------------------------
  236. // 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/]
  237. <1> The version of the snapshot policy, only the latest verison is stored and incremented when the policy is updated
  238. <2> The last time this policy was modified.
  239. <3> The next time this policy will be executed.
  240. [[slm-api-get-all-ex]]
  241. ===== Get all policies
  242. [source,console]
  243. --------------------------------------------------
  244. GET /_slm/policy
  245. --------------------------------------------------
  246. // TEST[continued]
  247. [[slm-api-execute]]
  248. === Execute Snapshot Lifecycle Policy API
  249. Sometimes it can be useful to immediately execute a snapshot based on policy,
  250. perhaps before an upgrade or before performing other maintenance on indices. The
  251. execute snapshot policy API allows you to perform a snapshot immediately without
  252. waiting for a policy's scheduled invocation.
  253. ==== Path Parameters
  254. `policy_id` (required)::
  255. (string) Id of the policy to execute
  256. ==== Example
  257. To take an immediate snapshot using a policy, use the following
  258. [source,console]
  259. --------------------------------------------------
  260. POST /_slm/policy/daily-snapshots/_execute
  261. --------------------------------------------------
  262. // TEST[skip:we can't easily handle snapshots from docs tests]
  263. This API will immediately return with the generated snapshot name
  264. [source,console-result]
  265. --------------------------------------------------
  266. {
  267. "snapshot_name": "daily-snap-2019.04.24-gwrqoo2xtea3q57vvg0uea"
  268. }
  269. --------------------------------------------------
  270. // TESTRESPONSE[skip:we can't handle snapshots from docs tests]
  271. The snapshot will be taken in the background, you can use the
  272. <<modules-snapshots,snapshot APIs>> to monitor the status of the snapshot.
  273. Once a snapshot has been kicked off, you can see the latest successful or failed
  274. snapshot using the get snapshot lifecycle policy API:
  275. [source,console]
  276. --------------------------------------------------
  277. GET /_slm/policy/daily-snapshots?human
  278. --------------------------------------------------
  279. // TEST[skip:we already tested get policy above, the last_failure may not be present though]
  280. Which, in this case shows an error because the index did not exist:
  281. [source,console-result]
  282. --------------------------------------------------
  283. {
  284. "daily-snapshots" : {
  285. "version": 1,
  286. "modified_date": "2019-04-23T01:30:00.000Z",
  287. "modified_date_millis": 1556048137314,
  288. "policy" : {
  289. "schedule": "0 30 1 * * ?",
  290. "name": "<daily-snap-{now/d}>",
  291. "repository": "my_repository",
  292. "config": {
  293. "indices": ["data-*", "important"],
  294. "ignore_unavailable": false,
  295. "include_global_state": false
  296. },
  297. "retention": {
  298. "expire_after": "30d",
  299. "min_count": 5,
  300. "max_count": 50
  301. }
  302. },
  303. "stats": {
  304. "policy": "daily-snapshots",
  305. "snapshots_taken": 0,
  306. "snapshots_failed": 1,
  307. "snapshots_deleted": 0,
  308. "snapshot_deletion_failures": 0
  309. }
  310. "last_failure": { <1>
  311. "snapshot_name": "daily-snap-2019.04.02-lohisb5ith2n8hxacaq3mw",
  312. "time_string": "2019-04-02T01:30:00.000Z",
  313. "time": 1556042030000,
  314. "details": "{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [important]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"important\",\"index_uuid\":\"_na_\",\"index\":\"important\",\"stack_trace\":\"[important] IndexNotFoundException[no such index [important]]\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.indexNotFoundException(IndexNameExpressionResolver.java:762)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.innerResolve(IndexNameExpressionResolver.java:714)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.resolve(IndexNameExpressionResolver.java:670)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndices(IndexNameExpressionResolver.java:163)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:142)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:102)\\n\\tat org.elasticsearch.snapshots.SnapshotsService$1.execute(SnapshotsService.java:280)\\n\\tat org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:47)\\n\\tat org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:687)\\n\\tat org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:310)\\n\\tat org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:210)\\n\\tat org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:142)\\n\\tat org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150)\\n\\tat org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188)\\n\\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:688)\\n\\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252)\\n\\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\\n\\tat java.base/java.lang.Thread.run(Thread.java:834)\\n\"}"
  315. } ,
  316. "next_execution": "2019-04-24T01:30:00.000Z",
  317. "next_execution_millis": 1556048160000
  318. }
  319. }
  320. --------------------------------------------------
  321. // TESTRESPONSE[skip:the presence of last_failure is asynchronous and will be present for users, but is untestable]
  322. <1> The last unsuccessfully initiated snapshot by this policy, along with the details of its failure
  323. In this case, it failed due to the "important" index not existing and
  324. `ignore_unavailable` setting being set to `false`.
  325. Updating the policy to change the `ignore_unavailable` setting is done using the
  326. same put snapshot lifecycle policy API:
  327. [source,console]
  328. --------------------------------------------------
  329. PUT /_slm/policy/daily-snapshots
  330. {
  331. "schedule": "0 30 1 * * ?",
  332. "name": "<daily-snap-{now/d}>",
  333. "repository": "my_repository",
  334. "config": {
  335. "indices": ["data-*", "important"],
  336. "ignore_unavailable": true,
  337. "include_global_state": false
  338. },
  339. "retention": {
  340. "expire_after": "30d",
  341. "min_count": 5,
  342. "max_count": 50
  343. }
  344. }
  345. --------------------------------------------------
  346. // TEST[continued]
  347. Another snapshot can immediately be executed to ensure the new policy works:
  348. [source,console]
  349. --------------------------------------------------
  350. POST /_slm/policy/daily-snapshots/_execute
  351. --------------------------------------------------
  352. // TEST[skip:we can't handle snapshots in docs tests]
  353. [source,console-result]
  354. --------------------------------------------------
  355. {
  356. "snapshot_name": "daily-snap-2019.04.24-tmtnyjtrsxkhbrrdcgg18a"
  357. }
  358. --------------------------------------------------
  359. // TESTRESPONSE[skip:we can't handle snapshots in docs tests]
  360. Now retriving the policy shows that the policy has successfully been executed:
  361. [source,console]
  362. --------------------------------------------------
  363. GET /_slm/policy/daily-snapshots?human
  364. --------------------------------------------------
  365. // TEST[skip:we already tested this above and the output may not be available yet]
  366. Which now includes the successful snapshot information:
  367. [source,console-result]
  368. --------------------------------------------------
  369. {
  370. "daily-snapshots" : {
  371. "version": 2, <1>
  372. "modified_date": "2019-04-23T01:30:00.000Z",
  373. "modified_date_millis": 1556048137314,
  374. "policy" : {
  375. "schedule": "0 30 1 * * ?",
  376. "name": "<daily-snap-{now/d}>",
  377. "repository": "my_repository",
  378. "config": {
  379. "indices": ["data-*", "important"],
  380. "ignore_unavailable": true,
  381. "include_global_state": false
  382. },
  383. "retention": {
  384. "expire_after": "30d",
  385. "min_count": 5,
  386. "max_count": 50
  387. }
  388. },
  389. "stats": {
  390. "policy": "daily-snapshots",
  391. "snapshots_taken": 1,
  392. "snapshots_failed": 1,
  393. "snapshots_deleted": 0,
  394. "snapshot_deletion_failures": 0
  395. },
  396. "last_success": { <2>
  397. "snapshot_name": "daily-snap-2019.04.24-tmtnyjtrsxkhbrrdcgg18a",
  398. "time_string": "2019-04-24T16:43:49.316Z",
  399. "time": 1556124229316
  400. } ,
  401. "last_failure": {
  402. "snapshot_name": "daily-snap-2019.04.02-lohisb5ith2n8hxacaq3mw",
  403. "time_string": "2019-04-02T01:30:00.000Z",
  404. "time": 1556042030000,
  405. "details": "{\"type\":\"index_not_found_exception\",\"reason\":\"no such index [important]\",\"resource.type\":\"index_or_alias\",\"resource.id\":\"important\",\"index_uuid\":\"_na_\",\"index\":\"important\",\"stack_trace\":\"[important] IndexNotFoundException[no such index [important]]\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.indexNotFoundException(IndexNameExpressionResolver.java:762)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.innerResolve(IndexNameExpressionResolver.java:714)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver$WildcardExpressionResolver.resolve(IndexNameExpressionResolver.java:670)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndices(IndexNameExpressionResolver.java:163)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:142)\\n\\tat org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.concreteIndexNames(IndexNameExpressionResolver.java:102)\\n\\tat org.elasticsearch.snapshots.SnapshotsService$1.execute(SnapshotsService.java:280)\\n\\tat org.elasticsearch.cluster.ClusterStateUpdateTask.execute(ClusterStateUpdateTask.java:47)\\n\\tat org.elasticsearch.cluster.service.MasterService.executeTasks(MasterService.java:687)\\n\\tat org.elasticsearch.cluster.service.MasterService.calculateTaskOutputs(MasterService.java:310)\\n\\tat org.elasticsearch.cluster.service.MasterService.runTasks(MasterService.java:210)\\n\\tat org.elasticsearch.cluster.service.MasterService$Batcher.run(MasterService.java:142)\\n\\tat org.elasticsearch.cluster.service.TaskBatcher.runIfNotProcessed(TaskBatcher.java:150)\\n\\tat org.elasticsearch.cluster.service.TaskBatcher$BatchedTask.run(TaskBatcher.java:188)\\n\\tat org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:688)\\n\\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.runAndClean(PrioritizedEsThreadPoolExecutor.java:252)\\n\\tat org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:215)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\\n\\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\\n\\tat java.base/java.lang.Thread.run(Thread.java:834)\\n\"}"
  406. } ,
  407. "next_execution": "2019-04-24T01:30:00.000Z",
  408. "next_execution_millis": 1556048160000
  409. }
  410. }
  411. --------------------------------------------------
  412. // TESTRESPONSE[skip:the presence of last_failure and last_success is asynchronous and will be present for users, but is untestable]
  413. <1> The policy's version has been incremented because it was updated
  414. <2> The last successfully initiated snapshot information
  415. It is a good idea to test policies using the execute API to ensure they work.
  416. [[slm-get-stats]]
  417. === Get Snapshot Lifecycle Stats API
  418. SLM stores statistics on a global and per-policy level about actions taken. These stats can be
  419. retrieved by using the following API:
  420. ==== Example
  421. [source,console]
  422. --------------------------------------------------
  423. GET /_slm/stats
  424. --------------------------------------------------
  425. // TEST[continued]
  426. Which returns a response similar to:
  427. [source,js]
  428. --------------------------------------------------
  429. {
  430. "retention_runs": 13,
  431. "retention_failed": 0,
  432. "retention_timed_out": 0,
  433. "retention_deletion_time": "1.4s",
  434. "retention_deletion_time_millis": 1404,
  435. "policy_stats": [ ],
  436. "total_snapshots_taken": 1,
  437. "total_snapshots_failed": 1,
  438. "total_snapshots_deleted": 0,
  439. "total_snapshot_deletion_failures": 0
  440. }
  441. --------------------------------------------------
  442. // TESTRESPONSE[s/runs": 13/runs": $body.retention_runs/ s/_failed": 0/_failed": $body.retention_failed/ s/_timed_out": 0/_timed_out": $body.retention_timed_out/ s/"1.4s"/$body.retention_deletion_time/ s/1404/$body.retention_deletion_time_millis/ s/total_snapshots_taken": 1/total_snapshots_taken": $body.total_snapshots_taken/ s/total_snapshots_failed": 1/total_snapshots_failed": $body.total_snapshots_failed/ s/"policy_stats": [.*]/"policy_stats": $body.policy_stats/]
  443. [[slm-api-delete]]
  444. === Delete Snapshot Lifecycle Policy API
  445. A policy can be deleted by issuing a delete request with the policy id. Note
  446. that this prevents any future snapshots from being taken, but does not cancel
  447. any currently ongoing snapshots or remove any previously taken snapshots.
  448. ==== Path Parameters
  449. `policy_id` (optional)::
  450. (string) Id of the policy to remove.
  451. ==== Example
  452. [source,console]
  453. --------------------------------------------------
  454. DELETE /_slm/policy/daily-snapshots
  455. --------------------------------------------------
  456. // TEST[continued]
  457. [[slm-api-execute-retention]]
  458. === Execute Snapshot Lifecycle Retention API
  459. While Snapshot Lifecycle Management retention is usually invoked through the global cluster settings
  460. for its schedule, it can sometimes be useful to invoke a retention run to expunge expired snapshots
  461. immediately. This API allows you to run a one-off retention run.
  462. ==== Example
  463. To immediately start snapshot retention, use the following
  464. [source,console]
  465. --------------------------------------------------
  466. POST /_slm/_execute_retention
  467. --------------------------------------------------
  468. This API will immediately return, as retention will be run asynchronously in the background:
  469. [source,console-result]
  470. --------------------------------------------------
  471. {
  472. "acknowledged": true
  473. }
  474. --------------------------------------------------