get-snapshot-status-api.asciidoc 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. [[get-snapshot-status-api]]
  2. === Get snapshot status API
  3. ++++
  4. <titleabbrev>Get snapshot status</titleabbrev>
  5. ++++
  6. Retrieves a detailed description of the current state for each shard participating in the snapshot.
  7. ////
  8. [source,console]
  9. ----
  10. PUT /index_1
  11. PUT /index_1/_doc/1
  12. {
  13. "title": "Elastic, Vol.1", "category": "Non-Fiction",
  14. "author": {
  15. "first_name": "Elk",
  16. "last_name": "Stack"
  17. }
  18. }
  19. PUT /index_1/_doc/2
  20. {
  21. "title": "Elastic, Vol.2", "category": "Non-Fiction",
  22. "author": {
  23. "first_name": "Elk",
  24. "last_name": "Stack"
  25. }
  26. }
  27. PUT /index_1/_doc/3
  28. {
  29. "title": "Elastic, Vol.3", "category": "Non-Fiction",
  30. "author": {
  31. "first_name": "Elk",
  32. "last_name": "Stack"
  33. }
  34. }
  35. PUT /index_1/_doc/4
  36. {
  37. "title": "Elastic, Vol.4", "category": "Non-Fiction",
  38. "author": {
  39. "first_name": "Elk",
  40. "last_name": "Stack"
  41. }
  42. }
  43. PUT /_snapshot/my_repository
  44. {
  45. "type": "fs",
  46. "settings": {
  47. "location": "my_backup_location"
  48. }
  49. }
  50. PUT /_snapshot/my_repository/my_snapshot?wait_for_completion=true
  51. PUT _snapshot/my_repository/snapshot_2?wait_for_completion=true
  52. {
  53. "indices": ["index_1"],
  54. "ignore_unavailable": true,
  55. "include_global_state": false,
  56. "metadata": {
  57. "taken_by": "Elastic Machine",
  58. "taken_because": "backup testing"
  59. }
  60. }
  61. ----
  62. // TESTSETUP
  63. ////
  64. [source,console]
  65. ----
  66. GET _snapshot/_status
  67. ----
  68. [[get-snapshot-status-api-request]]
  69. ==== {api-request-title}
  70. `GET _snapshot/_status`
  71. `GET _snapshot/<repository>/_status`
  72. `GET _snapshot/<repository>/<snapshot>/_status`
  73. [[get-snapshot-status-api-prereqs]]
  74. ==== {api-prereq-title}
  75. * If the {es} {security-features} are enabled, you must have the
  76. `monitor_snapshot`, `create_snapshot`, or `manage`
  77. <<privileges-list-cluster,cluster privilege>> to use this API.
  78. [[get-snapshot-status-api-desc]]
  79. ==== {api-description-title}
  80. Use the get snapshot status API to get detailed information about the shards
  81. participating in a snapshot.
  82. If you omit the `<snapshot>` request path parameter, the request only retrieves
  83. information for currently running snapshots. This usage is preferred.
  84. If needed, you can specify `<repository>` and `<snapshot>` to retrieve
  85. information for specific snapshots, even if they're not currently running.
  86. [WARNING]
  87. ====
  88. Using the API to return the status of any snapshots other than currently running
  89. snapshots can be expensive. The API requires a read from the repository for each
  90. shard in each snapshot. For example, if you have 100 snapshots with 1,000 shards
  91. each, an API request that includes all snapshots will require 100,000 reads (100
  92. snapshots * 1,000 shards).
  93. Depending on the latency of your storage, such requests can take an extremely
  94. long time to return results. These requests can also tax machine resources
  95. and, when using cloud storage, incur high processing costs.
  96. ====
  97. [[get-snapshot-status-api-path-params]]
  98. ==== {api-path-parms-title}
  99. `<repository>`::
  100. (Optional, string)
  101. Snapshot repository name used to limit the request. Supports wildcards (`*`) if
  102. `<snapshot>` isn't specified.
  103. `<snapshot>`::
  104. (Optional, string)
  105. Comma-separated list of snapshots to retrieve status for. Defaults to
  106. currently running snapshots. Wildcards (`*`) are not supported.
  107. [role="child_attributes"]
  108. [[get-snapshot-status-api-query-params]]
  109. ==== {api-query-parms-title}
  110. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=master-timeout]
  111. `ignore_unavailable`::
  112. (Optional, Boolean)
  113. If `false`, the request returns an error for any snapshots that are unavailable. Defaults to `false`.
  114. +
  115. If `true`, the request ignores snapshots that are unavailable, such as those that are corrupted or temporarily cannot be returned.
  116. [role="child_attributes"]
  117. [[get-snapshot-status-api-response-body]]
  118. ==== {api-response-body-title}
  119. `repository`::
  120. (string)
  121. Name of the repository that includes the snapshot.
  122. `snapshot`::
  123. (string)
  124. Name of the snapshot.
  125. `uuid`::
  126. (string)
  127. Universally unique identifier (UUID) of the snapshot.
  128. `state`::
  129. +
  130. --
  131. (string)
  132. Indicates the current snapshot state.
  133. .Values for `state`
  134. [%collapsible%open]
  135. ====
  136. `FAILED`::
  137. The snapshot finished with an error and failed to store any data.
  138. `STARTED`::
  139. The snapshot is currently running.
  140. `PARTIAL`::
  141. The global cluster state was stored, but data of at least one shard was not stored successfully.
  142. The <<get-snapshot-api-response-failures,`failures`>> section of the response contains more detailed information about shards
  143. that were not processed correctly.
  144. `SUCCESS`::
  145. The snapshot finished and all shards were stored successfully.
  146. ====
  147. --
  148. `include_global_state`::
  149. (Boolean)
  150. Indicates whether the current cluster state is included in the snapshot.
  151. [[get-snapshot-status-shards-stats]]
  152. `shards_stats`::
  153. (object)
  154. Contains a count of shards in the snapshot.
  155. +
  156. .Properties of `shards_stats`
  157. [%collapsible%open]
  158. ====
  159. `initializing`::
  160. (integer)
  161. Number of shards that are still initializing.
  162. `started`::
  163. (integer)
  164. Number of shards that have started but are not finalized.
  165. `finalizing`::
  166. (integer)
  167. Number of shards that are finalizing but are not done.
  168. `done`::
  169. (integer)
  170. Number of shards that initialized, started, and finalized successfully.
  171. `failed`::
  172. (integer)
  173. Number of shards that failed to be included in the snapshot.
  174. `total`::
  175. (integer)
  176. Total number of shards included in the snapshot.
  177. ====
  178. [[get-snapshot-status-stats]]
  179. `stats`::
  180. (object)
  181. Provides details on the number (`file_count`) and size (`size_in_bytes`) of files included in the snapshot.
  182. +
  183. .Properties of `stats`
  184. [%collapsible%open]
  185. ====
  186. `incremental`::
  187. (object)
  188. Number and size of files that still need to be copied as part of the incremental snapshot.
  189. +
  190. For completed snapshots, this property indicates the number and size
  191. of files that were not already in the repository and were copied as
  192. part of the incremental snapshot.
  193. `processed`::
  194. (object)
  195. Number and size of files that have already been uploaded to the snapshot. After a file is uploaded, the processed `file_count` and `size_in_bytes` are incremented in `stats`.
  196. `total`::
  197. (object)
  198. Total number and size of files that are referenced by the snapshot.
  199. [[get-snapshot-status-start-time]]
  200. `start_time_in_millis`::
  201. (long)
  202. The time, in milliseconds, when the snapshot creation process started.
  203. [[get-snapshot-status-total-time]]
  204. `time_in_millis`::
  205. (long)
  206. The total time, in milliseconds, that it took for the snapshot process
  207. to complete.
  208. ====
  209. `<index>`::
  210. (list of objects)
  211. List of objects containing information about the
  212. indices included in the snapshot.
  213. +
  214. .Properties of `<index>`
  215. [%collapsible%open]
  216. ====
  217. `shards_stats`::
  218. (object)
  219. See <<get-snapshot-status-shards-stats,`shards_stats`>>.
  220. `stats`::
  221. (object)
  222. See <<get-snapshot-status-stats,`stats`>>.
  223. `shards`::
  224. (list of objects)
  225. List of objects containing information about the
  226. shards that include the snapshot.
  227. +
  228. .Properties of `shards`
  229. [%collapsible%open]
  230. =====
  231. `stage`::
  232. (string)
  233. Indicates the current state of the shards that include the snapshot.
  234. +
  235. .Properties of `stage`
  236. [%collapsible%open]
  237. ======
  238. `DONE`::
  239. Number of shards in the snapshot that were successfully stored in the repository.
  240. `FAILURE`::
  241. Number of shards in the snapshot that were not successfully stored in
  242. the repository.
  243. `FINALIZE`::
  244. Number of shards in the snapshot that are in the finalizing stage
  245. of being stored in the repository.
  246. `INIT`::
  247. Number of shards in the snapshot that are in the initializing stage
  248. of being stored in the repository.
  249. `STARTED`::
  250. Number of shards in the snapshot that are in the started stage
  251. of being stored in the repository.
  252. ======
  253. `stats`::
  254. (object)
  255. See <<get-snapshot-status-stats,`stats`>>.
  256. `total`::
  257. (object)
  258. Total number and size of files that are referenced by the snapshot.
  259. `start_time_in_millis`::
  260. (long)
  261. See <<get-snapshot-status-start-time,`start_time_in_millis`>>.
  262. `time_in_millis`::
  263. (long)
  264. See <<get-snapshot-status-total-time,`time_in_millis`>>.
  265. =====
  266. ====
  267. [[get-snapshot-status-api-example]]
  268. ==== {api-example-title}
  269. The following request returns detailed status information for `snapshot_2` in the `my_repository` repository. This response includes additional information beyond the <<get-snapshot-api,Get snapshot API>>, such as shard status and file statistics.
  270. [source,console]
  271. ----
  272. GET _snapshot/my_repository/snapshot_2/_status
  273. ----
  274. [source,console-result]
  275. ----
  276. {
  277. "snapshots" : [
  278. {
  279. "snapshot" : "snapshot_2",
  280. "repository" : "my_repository",
  281. "uuid" : "lNeQD1SvTQCqqJUMQSwmGg",
  282. "state" : "SUCCESS",
  283. "include_global_state" : false,
  284. "shards_stats" : {
  285. "initializing" : 0,
  286. "started" : 0,
  287. "finalizing" : 0,
  288. "done" : 1,
  289. "failed" : 0,
  290. "total" : 1
  291. },
  292. "stats" : {
  293. "incremental" : {
  294. "file_count" : 3,
  295. "size_in_bytes" : 5969
  296. },
  297. "total" : {
  298. "file_count" : 4,
  299. "size_in_bytes" : 6024
  300. },
  301. "start_time_in_millis" : 1594829326691,
  302. "time_in_millis" : 205
  303. },
  304. "indices" : {
  305. "index_1" : {
  306. "shards_stats" : {
  307. "initializing" : 0,
  308. "started" : 0,
  309. "finalizing" : 0,
  310. "done" : 1,
  311. "failed" : 0,
  312. "total" : 1
  313. },
  314. "stats" : {
  315. "incremental" : {
  316. "file_count" : 3,
  317. "size_in_bytes" : 5969
  318. },
  319. "total" : {
  320. "file_count" : 4,
  321. "size_in_bytes" : 6024
  322. },
  323. "start_time_in_millis" : 1594829326896,
  324. "time_in_millis" : 0
  325. },
  326. "shards" : {
  327. "0" : {
  328. "stage" : "DONE",
  329. "stats" : {
  330. "incremental" : {
  331. "file_count" : 3,
  332. "size_in_bytes" : 5969
  333. },
  334. "total" : {
  335. "file_count" : 4,
  336. "size_in_bytes" : 6024
  337. },
  338. "start_time_in_millis" : 1594829326896,
  339. "time_in_millis" : 0
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. ]
  347. }
  348. ----
  349. // TESTRESPONSE[s/"uuid" : "lNeQD1SvTQCqqJUMQSwmGg"/"uuid" : $body.snapshots.0.uuid/]
  350. // TESTRESPONSE[s/"size_in_bytes" : 6024/"size_in_bytes" : $body.snapshots.0.stats.total.size_in_bytes/]
  351. // TESTRESPONSE[s/"done" : 10/"done" : $body.snapshots.0.shards_stats.done/]
  352. // TESTRESPONSE[s/"total" : 10/"total" : $body.snapshots.0.shards_stats.total/]
  353. // TESTRESPONSE[s/"start_time_in_millis" : 1594829326691/"start_time_in_millis" : $body.snapshots.0.stats.start_time_in_millis/]
  354. // TESTRESPONSE[s/"time_in_millis" : 205/"time_in_millis" : $body.snapshots.0.stats.time_in_millis/]
  355. // TESTRESPONSE[s/"time_in_millis" : 0/"time_in_millis" : $body.$_path/]
  356. // TESTRESPONSE[s/"file_count" : 3/"file_count" : $body.snapshots.0.stats.incremental.file_count/]
  357. // TESTRESPONSE[s/"file_count" : 4/"file_count" : $body.snapshots.0.stats.total.file_count/]
  358. // TESTRESPONSE[s/"size_in_bytes" : 5969/"size_in_bytes" : $body.snapshots.0.stats.incremental.size_in_bytes/]
  359. // TESTRESPONSE[s/"start_time_in_millis" : 1594829326896/"start_time_in_millis" : $body.snapshots.0.indices.index_1.stats.start_time_in_millis/]