get-snapshot-status-api.asciidoc 11 KB

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